mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
fixed trailing \\uFE0F on DOM parsing
This commit is contained in:
parent
72b5e44e09
commit
2d8c1a7e72
@ -89,7 +89,7 @@ define(function () {
|
||||
*/
|
||||
onerror: function onerror() {
|
||||
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
|
||||
* @return Node a DOM node with that text
|
||||
*/
|
||||
function createText(text) {
|
||||
return document.createTextNode(text);
|
||||
function createText(text, clean) {
|
||||
return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,7 +367,7 @@ define(function () {
|
||||
index = match.index;
|
||||
if (index !== i) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i, index))
|
||||
createText(text.slice(i, index), true)
|
||||
);
|
||||
}
|
||||
rawText = match[0];
|
||||
@ -395,7 +395,7 @@ define(function () {
|
||||
modified = true;
|
||||
fragment.appendChild(img);
|
||||
}
|
||||
if (!img) fragment.appendChild(createText(rawText));
|
||||
if (!img) fragment.appendChild(createText(rawText, false));
|
||||
img = null;
|
||||
}
|
||||
// is there actually anything to replace in here ?
|
||||
@ -403,7 +403,7 @@ define(function () {
|
||||
// any text left to be added ?
|
||||
if (i < text.length) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i))
|
||||
createText(text.slice(i), true)
|
||||
);
|
||||
}
|
||||
// replace the text node only, leave intact
|
||||
|
12
2/twemoji.js
12
2/twemoji.js
@ -88,7 +88,7 @@ var twemoji = (function (
|
||||
*/
|
||||
onerror: function onerror() {
|
||||
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
|
||||
* @return Node a DOM node with that text
|
||||
*/
|
||||
function createText(text) {
|
||||
return document.createTextNode(text);
|
||||
function createText(text, clean) {
|
||||
return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,7 +366,7 @@ var twemoji = (function (
|
||||
index = match.index;
|
||||
if (index !== i) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i, index))
|
||||
createText(text.slice(i, index), true)
|
||||
);
|
||||
}
|
||||
rawText = match[0];
|
||||
@ -394,7 +394,7 @@ var twemoji = (function (
|
||||
modified = true;
|
||||
fragment.appendChild(img);
|
||||
}
|
||||
if (!img) fragment.appendChild(createText(rawText));
|
||||
if (!img) fragment.appendChild(createText(rawText, false));
|
||||
img = null;
|
||||
}
|
||||
// is there actually anything to replace in here ?
|
||||
@ -402,7 +402,7 @@ var twemoji = (function (
|
||||
// any text left to be added ?
|
||||
if (i < text.length) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i))
|
||||
createText(text.slice(i), true)
|
||||
);
|
||||
}
|
||||
// replace the text node only, leave intact
|
||||
|
2
2/twemoji.min.js
vendored
2
2/twemoji.min.js
vendored
File diff suppressed because one or more lines are too long
@ -89,7 +89,7 @@ var twemoji = (function (
|
||||
*/
|
||||
onerror: function onerror() {
|
||||
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
|
||||
* @return Node a DOM node with that text
|
||||
*/
|
||||
function createText(text) {
|
||||
return document.createTextNode(text);
|
||||
function createText(text, clean) {
|
||||
return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,7 +367,7 @@ var twemoji = (function (
|
||||
index = match.index;
|
||||
if (index !== i) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i, index))
|
||||
createText(text.slice(i, index), true)
|
||||
);
|
||||
}
|
||||
rawText = match[0];
|
||||
@ -395,7 +395,7 @@ var twemoji = (function (
|
||||
modified = true;
|
||||
fragment.appendChild(img);
|
||||
}
|
||||
if (!img) fragment.appendChild(createText(rawText));
|
||||
if (!img) fragment.appendChild(createText(rawText, false));
|
||||
img = null;
|
||||
}
|
||||
// is there actually anything to replace in here ?
|
||||
@ -403,7 +403,7 @@ var twemoji = (function (
|
||||
// any text left to be added ?
|
||||
if (i < text.length) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i))
|
||||
createText(text.slice(i), true)
|
||||
);
|
||||
}
|
||||
// replace the text node only, leave intact
|
||||
|
@ -576,7 +576,7 @@ function createTwemoji(re) {
|
||||
*/
|
||||
onerror: function onerror() {
|
||||
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
|
||||
* @return Node a DOM node with that text
|
||||
*/
|
||||
function createText(text) {
|
||||
return document.createTextNode(text);
|
||||
function createText(text, clean) {
|
||||
return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -854,7 +854,7 @@ function createTwemoji(re) {
|
||||
index = match.index;
|
||||
if (index !== i) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i, index))
|
||||
createText(text.slice(i, index), true)
|
||||
);
|
||||
}
|
||||
rawText = match[0];
|
||||
@ -882,7 +882,7 @@ function createTwemoji(re) {
|
||||
modified = true;
|
||||
fragment.appendChild(img);
|
||||
}
|
||||
if (!img) fragment.appendChild(createText(rawText));
|
||||
if (!img) fragment.appendChild(createText(rawText, false));
|
||||
img = null;
|
||||
}
|
||||
// is there actually anything to replace in here ?
|
||||
@ -890,7 +890,7 @@ function createTwemoji(re) {
|
||||
// any text left to be added ?
|
||||
if (i < text.length) {
|
||||
fragment.appendChild(
|
||||
createText(text.slice(i))
|
||||
createText(text.slice(i), true)
|
||||
);
|
||||
}
|
||||
// replace the text node only, leave intact
|
||||
@ -1057,7 +1057,7 @@ function createTwemoji(re) {
|
||||
// drop current indentation
|
||||
.replace(/^ /gm, '')
|
||||
// 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
|
||||
.replace('/*! (C) Twitter Inc. */',
|
||||
'/*! (C) Twitter Inc. *//*\n' +
|
||||
|
1
2/utils/re
Normal file
1
2/utils/re
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user