File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff 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 , {
You can’t perform that action at this time.
0 commit comments