Emoji: before parsing added nodes test if the text in them contains emoji chars. That speeds up the processing quite a bit.
See #32125. git-svn-id: https://develop.svn.wordpress.org/trunk@32335 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9c3c452fa9
commit
6368ee0c6a
@ -70,7 +70,7 @@
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
if ( node && node.nodeType === 1 ) {
|
||||
if ( node && node.nodeType === 1 && test( node.textContent ) ) {
|
||||
parse( node );
|
||||
}
|
||||
}
|
||||
@ -84,6 +84,22 @@
|
||||
parse( document.body );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a text string contains emoji characters
|
||||
*
|
||||
* @since 4.3.0
|
||||
*
|
||||
* @param {String} text The string to test
|
||||
* @returns Boolean
|
||||
*/
|
||||
function test( text ) {
|
||||
if ( text && twemoji ) {
|
||||
return twemoji.test( text );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an element or string, parse any emoji characters into Twemoji images.
|
||||
*
|
||||
@ -144,7 +160,8 @@
|
||||
|
||||
return {
|
||||
replaceEmoji: replaceEmoji,
|
||||
parse: parse
|
||||
parse: parse,
|
||||
test: test
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user