Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/js/_enqueues/vendor/twemoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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 <img> tags
// otherwise use the DOM tree and parse text nodes only
return (typeof what === 'string' ? parseString : parseNode)(what, {
Expand Down
Loading