mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-07 22:24:36 +00:00
Emoji: Always skip nodes with the wp-exclude-emoji CSS class.
Patches twemoji.js to add support for a `doNotParse()` callback. Uses that callback to always exclude emojis in HTML elements with the above class. Props: dd32, peterwilsoncc, azaozz. Fixes #52219. git-svn-id: https://develop.svn.wordpress.org/trunk@55186 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
589
src/js/_enqueues/vendor/twemoji.js
vendored
Normal file
589
src/js/_enqueues/vendor/twemoji.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -145,17 +145,6 @@
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the class name of a non-element node contains 'wp-exclude-emoji' ignore it.
|
||||
*
|
||||
* Node type 1 is an ELEMENT_NODE.
|
||||
*/
|
||||
if ( ! node || node.nodeType !== 1 ||
|
||||
( node.className && typeof node.className === 'string' && node.className.indexOf( 'wp-exclude-emoji' ) !== -1 ) ) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( test( node.textContent ) ) {
|
||||
parse( node );
|
||||
}
|
||||
@@ -263,6 +252,19 @@
|
||||
this.setAttribute( 'data-error', 'load-failed' );
|
||||
twemoji.parentNode.replaceChild( document.createTextNode( twemoji.alt ), twemoji );
|
||||
}
|
||||
},
|
||||
doNotParse: function( node ) {
|
||||
if (
|
||||
node &&
|
||||
node.className &&
|
||||
typeof node.className === 'string' &&
|
||||
node.className.indexOf( 'wp-exclude-emoji' ) !== -1
|
||||
) {
|
||||
// Do not parse this node. Emojis will not be replaced in this node and all sub-nodes.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user