Emoji: Update Twemoji to 2.5.0.
Twemoji 2.3.0 has a rendering issue in Safari, emoji can sometimes be followed by U+FEOF (which is just a flag meaning "render the preceding character as emoji). Twemoji wasn't catching this character correctly, and Safari rendered it incorrectly. Twemoji 2.5.0 resolves this issue. Fixes #41584. git-svn-id: https://develop.svn.wordpress.org/trunk@41250 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
21f8256a27
commit
0e31ef4e2c
@ -88,7 +88,7 @@ var twemoji = (function (
|
|||||||
*/
|
*/
|
||||||
onerror: function onerror() {
|
onerror: function onerror() {
|
||||||
if (this.parentNode) {
|
if (this.parentNode) {
|
||||||
this.parentNode.replaceChild(createText(this.alt), this);
|
this.parentNode.replaceChild(createText(this.alt, false), this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -159,13 +159,13 @@ var twemoji = (function (
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* twemoji.parse("I \u2764\uFE0F emoji!");
|
* twemoji.parse("I \u2764\uFE0F emoji!");
|
||||||
* // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"> emoji!
|
* // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"/> emoji!
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* twemoji.parse("I \u2764\uFE0F emoji!", function(iconId, options) {
|
* twemoji.parse("I \u2764\uFE0F emoji!", function(iconId, options) {
|
||||||
* return '/assets/' + iconId + '.gif';
|
* return '/assets/' + iconId + '.gif';
|
||||||
* });
|
* });
|
||||||
* // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"> emoji!
|
* // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"/> emoji!
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* twemoji.parse("I \u2764\uFE0F emoji!", {
|
* twemoji.parse("I \u2764\uFE0F emoji!", {
|
||||||
@ -174,7 +174,7 @@ var twemoji = (function (
|
|||||||
* return '/assets/' + options.size + '/' + iconId + options.ext;
|
* return '/assets/' + options.size + '/' + iconId + options.ext;
|
||||||
* }
|
* }
|
||||||
* });
|
* });
|
||||||
* // I <img class="emoji" draggable="false" alt="❤️" src="/assets/72x72/2764.png"> emoji!
|
* // I <img class="emoji" draggable="false" alt="❤️" src="/assets/72x72/2764.png"/> emoji!
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
parse: parse,
|
parse: parse,
|
||||||
@ -237,8 +237,8 @@ var twemoji = (function (
|
|||||||
// used to find HTML special chars in attributes
|
// used to find HTML special chars in attributes
|
||||||
rescaper = /[&<>'"]/g,
|
rescaper = /[&<>'"]/g,
|
||||||
|
|
||||||
// nodes with type 1 which should **not** be parsed (including lower case svg)
|
// nodes with type 1 which should **not** be parsed
|
||||||
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]/,
|
shouldntBeParsed = /^(?:iframe|noframes|noscript|script|select|style|textarea)$/,
|
||||||
|
|
||||||
// just a private shortcut
|
// just a private shortcut
|
||||||
fromCharCode = String.fromCharCode;
|
fromCharCode = String.fromCharCode;
|
||||||
@ -256,8 +256,8 @@ var twemoji = (function (
|
|||||||
* @param string text used to create DOM text node
|
* @param string text used to create DOM text node
|
||||||
* @return Node a DOM node with that text
|
* @return Node a DOM node with that text
|
||||||
*/
|
*/
|
||||||
function createText(text) {
|
function createText(text, clean) {
|
||||||
return document.createTextNode(text);
|
return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,9 +301,10 @@ var twemoji = (function (
|
|||||||
// collect them to process emoji later
|
// collect them to process emoji later
|
||||||
allText.push(subnode);
|
allText.push(subnode);
|
||||||
}
|
}
|
||||||
// ignore all nodes that are not type 1 or that
|
// ignore all nodes that are not type 1, that are svg, or that
|
||||||
// should not be parsed as script, style, and others
|
// should not be parsed as script, style, and others
|
||||||
else if (nodeType === 1 && !shouldntBeParsed.test(subnode.nodeName)) {
|
else if (nodeType === 1 && !('ownerSVGElement' in subnode) &&
|
||||||
|
!shouldntBeParsed.test(subnode.nodeName.toLowerCase())) {
|
||||||
grabAllTextNodes(subnode, allText);
|
grabAllTextNodes(subnode, allText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,7 +366,7 @@ var twemoji = (function (
|
|||||||
index = match.index;
|
index = match.index;
|
||||||
if (index !== i) {
|
if (index !== i) {
|
||||||
fragment.appendChild(
|
fragment.appendChild(
|
||||||
createText(text.slice(i, index))
|
createText(text.slice(i, index), true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
rawText = match[0];
|
rawText = match[0];
|
||||||
@ -393,7 +394,7 @@ var twemoji = (function (
|
|||||||
modified = true;
|
modified = true;
|
||||||
fragment.appendChild(img);
|
fragment.appendChild(img);
|
||||||
}
|
}
|
||||||
if (!img) fragment.appendChild(createText(rawText));
|
if (!img) fragment.appendChild(createText(rawText, false));
|
||||||
img = null;
|
img = null;
|
||||||
}
|
}
|
||||||
// is there actually anything to replace in here ?
|
// is there actually anything to replace in here ?
|
||||||
@ -401,7 +402,7 @@ var twemoji = (function (
|
|||||||
// any text left to be added ?
|
// any text left to be added ?
|
||||||
if (i < text.length) {
|
if (i < text.length) {
|
||||||
fragment.appendChild(
|
fragment.appendChild(
|
||||||
createText(text.slice(i))
|
createText(text.slice(i), true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// replace the text node only, leave intact
|
// replace the text node only, leave intact
|
||||||
@ -459,7 +460,7 @@ var twemoji = (function (
|
|||||||
ret = ret.concat(' ', attrname, '="', escapeHTML(attrib[attrname]), '"');
|
ret = ret.concat(' ', attrname, '="', escapeHTML(attrib[attrname]), '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = ret.concat('>');
|
ret = ret.concat('/>');
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user