1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-10-02 21:02:03 +00:00

fixed trailing \\uFE0F on DOM parsing

This commit is contained in:
Andrea Giammarchi 2017-08-08 10:14:48 +01:00
parent 72b5e44e09
commit 2d8c1a7e72
6 changed files with 27 additions and 26 deletions

View File

@ -89,7 +89,7 @@ define(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);
} }
}, },
@ -257,8 +257,8 @@ define(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);
} }
/** /**
@ -367,7 +367,7 @@ define(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];
@ -395,7 +395,7 @@ define(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 ?
@ -403,7 +403,7 @@ define(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

View File

@ -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);
} }
}, },
@ -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);
} }
/** /**
@ -366,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];
@ -394,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 ?
@ -402,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

2
2/twemoji.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -89,7 +89,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);
} }
}, },
@ -257,8 +257,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);
} }
/** /**
@ -367,7 +367,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];
@ -395,7 +395,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 ?
@ -403,7 +403,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

View File

@ -576,7 +576,7 @@ function createTwemoji(re) {
*/ */
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);
} }
}, },
@ -744,8 +744,8 @@ function createTwemoji(re) {
* @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);
} }
/** /**
@ -854,7 +854,7 @@ function createTwemoji(re) {
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];
@ -882,7 +882,7 @@ function createTwemoji(re) {
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 ?
@ -890,7 +890,7 @@ function createTwemoji(re) {
// 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
@ -1057,7 +1057,7 @@ function createTwemoji(re) {
// drop current indentation // drop current indentation
.replace(/^ /gm, '') .replace(/^ /gm, '')
// add the RegExp in the right place // add the RegExp in the right place
.replace('re = /twemoji/', 're = /' + re + '/g') .replace('re = /twemoji/', 're = /' + fs.readFileSync(__dirname + '/re').toString() + '/g')
// add the full license // add the full license
.replace('/*! (C) Twitter Inc. */', .replace('/*! (C) Twitter Inc. */',
'/*! (C) Twitter Inc. *//*\n' + '/*! (C) Twitter Inc. *//*\n' +

1
2/utils/re Normal file

File diff suppressed because one or more lines are too long