Changeset 41250
- Timestamp:
- 08/14/2017 02:03:18 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/twemoji.js
r40837 r41250 89 89 onerror: function onerror() { 90 90 if (this.parentNode) { 91 this.parentNode.replaceChild(createText(this.alt ), this);91 this.parentNode.replaceChild(createText(this.alt, false), this); 92 92 } 93 93 }, … … 160 160 * 161 161 * twemoji.parse("I \u2764\uFE0F emoji!"); 162 * // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif" > emoji!162 * // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"/> emoji! 163 163 * 164 164 * … … 166 166 * return '/assets/' + iconId + '.gif'; 167 167 * }); 168 * // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif" > emoji!168 * // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"/> emoji! 169 169 * 170 170 * … … 175 175 * } 176 176 * }); 177 * // I <img class="emoji" draggable="false" alt="❤️" src="/assets/72x72/2764.png" > emoji!177 * // I <img class="emoji" draggable="false" alt="❤️" src="/assets/72x72/2764.png"/> emoji! 178 178 * 179 179 */ … … 238 238 rescaper = /[&<>'"]/g, 239 239 240 // nodes with type 1 which should **not** be parsed (including lower case svg)241 shouldntBeParsed = / IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]/,240 // nodes with type 1 which should **not** be parsed 241 shouldntBeParsed = /^(?:iframe|noframes|noscript|script|select|style|textarea)$/, 242 242 243 243 // just a private shortcut … … 257 257 * @return Node a DOM node with that text 258 258 */ 259 function createText(text ) {260 return document.createTextNode( text);259 function createText(text, clean) { 260 return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text); 261 261 } 262 262 … … 302 302 allText.push(subnode); 303 303 } 304 // ignore all nodes that are not type 1 or that304 // ignore all nodes that are not type 1, that are svg, or that 305 305 // should not be parsed as script, style, and others 306 else if (nodeType === 1 && !shouldntBeParsed.test(subnode.nodeName)) { 306 else if (nodeType === 1 && !('ownerSVGElement' in subnode) && 307 !shouldntBeParsed.test(subnode.nodeName.toLowerCase())) { 307 308 grabAllTextNodes(subnode, allText); 308 309 } … … 366 367 if (index !== i) { 367 368 fragment.appendChild( 368 createText(text.slice(i, index) )369 createText(text.slice(i, index), true) 369 370 ); 370 371 } … … 394 395 fragment.appendChild(img); 395 396 } 396 if (!img) fragment.appendChild(createText(rawText ));397 if (!img) fragment.appendChild(createText(rawText, false)); 397 398 img = null; 398 399 } … … 402 403 if (i < text.length) { 403 404 fragment.appendChild( 404 createText(text.slice(i) )405 createText(text.slice(i), true) 405 406 ); 406 407 } … … 460 461 } 461 462 } 462 ret = ret.concat(' >');463 ret = ret.concat('/>'); 463 464 } 464 465 return ret;
Note: See TracChangeset
for help on using the changeset viewer.