diff --git a/src/js/_enqueues/vendor/twemoji.js b/src/js/_enqueues/vendor/twemoji.js index 28091ec615792..c78259e99da91 100644 --- a/src/js/_enqueues/vendor/twemoji.js +++ b/src/js/_enqueues/vendor/twemoji.js @@ -305,6 +305,14 @@ var twemoji = (function ( // should not be parsed as script, style, and others else if (nodeType === 1 && !('ownerSVGElement' in subnode) && !shouldntBeParsed.test(subnode.nodeName.toLowerCase())) { + + // WP start + // Use doNotParse() callback if set. + if ( twemoji.doNotParse && twemoji.doNotParse( subnode ) ) { + continue; + } + // WP end + grabAllTextNodes(subnode, allText); } } @@ -520,6 +528,14 @@ var twemoji = (function ( if (!how || typeof how === 'function') { how = {callback: how}; } + + // WP start + // Allow passing of the doNotParse() callback in the settings. + // The callback is used in `grabAllTextNodes()` (DOM mode only) as a filter + // that allows bypassing of some of the text nodes. It gets the current subnode as argument. + twemoji.doNotParse = how.doNotParse; + // WP end + // if first argument is string, inject html tags // otherwise use the DOM tree and parse text nodes only return (typeof what === 'string' ? parseString : parseNode)(what, {