Skip to content

Commit 855ce99

Browse files
committed
Re-add WP specific modifications for Twemoji
1 parent 6e2130c commit 855ce99

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/js/_enqueues/vendor/twemoji.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ var twemoji = (function (
305305
// should not be parsed as script, style, and others
306306
else if (nodeType === 1 && !('ownerSVGElement' in subnode) &&
307307
!shouldntBeParsed.test(subnode.nodeName.toLowerCase())) {
308+
309+
// WP start
310+
// Use doNotParse() callback if set.
311+
if ( twemoji.doNotParse && twemoji.doNotParse( subnode ) ) {
312+
continue;
313+
}
314+
// WP end
315+
308316
grabAllTextNodes(subnode, allText);
309317
}
310318
}
@@ -520,6 +528,14 @@ var twemoji = (function (
520528
if (!how || typeof how === 'function') {
521529
how = {callback: how};
522530
}
531+
532+
// WP start
533+
// Allow passing of the doNotParse() callback in the settings.
534+
// The callback is used in `grabAllTextNodes()` (DOM mode only) as a filter
535+
// that allows bypassing of some of the text nodes. It gets the current subnode as argument.
536+
twemoji.doNotParse = how.doNotParse;
537+
// WP end
538+
523539
// if first argument is string, inject html <img> tags
524540
// otherwise use the DOM tree and parse text nodes only
525541
return (typeof what === 'string' ? parseString : parseNode)(what, {

0 commit comments

Comments
 (0)