Skip to content

Commit 376800e

Browse files
committed
Emoji: Re-add WordPress modifications to Twemoji.
This re-adds some WordPress specific modifications to the Twemoji library that were accidentally removed in [57626] and [61134]. Unprops desrosj. Props dd32, paulkevan, ellatrix. See #64184. git-svn-id: https://develop.svn.wordpress.org/trunk@61180 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6e2130c commit 376800e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/js/_enqueues/vendor/twemoji.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ var twemoji = (function (
44
https://github.com/jdecked/twemoji/blob/gh-pages/LICENSE
55
*/
66

7+
/*
8+
* Note: this file was modified in two places to add support for a doNotParse() callback.
9+
* The modifications are surrounded by `// WP start` and `// WP end` comments.
10+
*/
11+
712
// WARNING: this file is generated automatically via
813
// `node scripts/build.js`
914
// please update its `createTwemoji` function
@@ -305,6 +310,14 @@ var twemoji = (function (
305310
// should not be parsed as script, style, and others
306311
else if (nodeType === 1 && !('ownerSVGElement' in subnode) &&
307312
!shouldntBeParsed.test(subnode.nodeName.toLowerCase())) {
313+
314+
// WP start
315+
// Use doNotParse() callback if set.
316+
if ( twemoji.doNotParse && twemoji.doNotParse( subnode ) ) {
317+
continue;
318+
}
319+
// WP end
320+
308321
grabAllTextNodes(subnode, allText);
309322
}
310323
}
@@ -520,6 +533,14 @@ var twemoji = (function (
520533
if (!how || typeof how === 'function') {
521534
how = {callback: how};
522535
}
536+
537+
// WP start
538+
// Allow passing of the doNotParse() callback in the settings.
539+
// The callback is used in `grabAllTextNodes()` (DOM mode only) as a filter
540+
// that allows bypassing of some of the text nodes. It gets the current subnode as argument.
541+
twemoji.doNotParse = how.doNotParse;
542+
// WP end
543+
523544
// if first argument is string, inject html <img> tags
524545
// otherwise use the DOM tree and parse text nodes only
525546
return (typeof what === 'string' ? parseString : parseNode)(what, {

0 commit comments

Comments
 (0)