How to use the @wordpress/dom.replace function in @wordpress/dom

To help you get started, we’ve selected a few @wordpress/dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / wordpress__dom / wordpress__dom-tests.ts View on Github external
dom.placeCaretAtHorizontalEdge(element, true);

// $ExpectType void
dom.placeCaretAtHorizontalEdge(undefined, false);

// $ExpectType void
dom.placeCaretAtVerticalEdge(element, true);

// $ExpectType void
dom.placeCaretAtVerticalEdge(undefined, false);

// $ExpectType void
dom.remove(node);

// $ExpectType void
dom.replace(node, node);

// $ExpectType HTMLParagraphElement
dom.replaceTag(node, 'p');

// $ExpectType HTMLSpanElement
dom.replaceTag(node, 'span');

// $ExpectType void
dom.unwrap(node);

// $ExpectType void
dom.wrap(node, node);
github WordPress / gutenberg / packages / blocks / src / api / raw-handling / special-comment-converter.js View on Github external
export default function( node, doc ) {
	if ( node.nodeType !== COMMENT_NODE ) {
		return;
	}

	if ( node.nodeValue === 'nextpage' ) {
		replace( node, createNextpage( doc ) );
		return;
	}

	if ( node.nodeValue.indexOf( 'more' ) === 0 ) {
		// Grab any custom text in the comment.
		const customText = node.nodeValue.slice( 4 ).trim();

		/*
		 * When a `` comment is found, we need to look for any
		 * `` sibling, but it may not be a direct sibling
		 * (whitespace typically lies in between)
		 */
		let sibling = node;
		let noTeaser = false;
		while ( ( sibling = sibling.nextSibling ) ) {
			if (
github WordPress / gutenberg / packages / blocks / src / api / raw-handling / special-comment-converter.js View on Github external
* (whitespace typically lies in between)
		 */
		let sibling = node;
		let noTeaser = false;
		while ( ( sibling = sibling.nextSibling ) ) {
			if (
				sibling.nodeType === COMMENT_NODE &&
				sibling.nodeValue === 'noteaser'
			) {
				noTeaser = true;
				remove( sibling );
				break;
			}
		}

		replace( node, createMore( customText, noTeaser, doc ) );
	}
}