1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-10-01 12:24:23 +00:00

Merge pull request #126 from twuttke/200D_minifier_protection

Alternate way to avoid using \u 200d
This commit is contained in:
Andrea Giammarchi 2016-03-02 19:03:54 +00:00
commit b2738a248e
6 changed files with 18 additions and 6 deletions

View File

@ -232,6 +232,9 @@ define(function () {
// not JIT based, and old browsers / engines
UFE0Fg = /\uFE0F/g,
// avoid using a string literal like '\u200D' here because minifiers expand it inline
U200D = String.fromCharCode(0x200D),
// used to find HTML special chars in attributes
rescaper = /[&<>'"]/g,
@ -316,7 +319,7 @@ define(function () {
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
return toCodePoint(rawText.indexOf(U200D) < 0 ?
rawText.replace(UFE0Fg, '') :
rawText
);

View File

@ -231,6 +231,9 @@ var twemoji = (function (
// not JIT based, and old browsers / engines
UFE0Fg = /\uFE0F/g,
// avoid using a string literal like '\u200D' here because minifiers expand it inline
U200D = String.fromCharCode(0x200D),
// used to find HTML special chars in attributes
rescaper = /[&<>'"]/g,
@ -315,7 +318,7 @@ var twemoji = (function (
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
return toCodePoint(rawText.indexOf(U200D) < 0 ?
rawText.replace(UFE0Fg, '') :
rawText
);

2
2/twemoji.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -232,6 +232,9 @@ var twemoji = (function (
// not JIT based, and old browsers / engines
UFE0Fg = /\uFE0F/g,
// avoid using a string literal like '\u200D' here because minifiers expand it inline
U200D = String.fromCharCode(0x200D),
// used to find HTML special chars in attributes
rescaper = /[&<>'"]/g,
@ -316,7 +319,7 @@ var twemoji = (function (
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
return toCodePoint(rawText.indexOf(U200D) < 0 ?
rawText.replace(UFE0Fg, '') :
rawText
);

View File

@ -45,7 +45,7 @@ require('child_process').spawn(
fs.writeFileSync(
file('twemoji.min.js'),
'/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */\n' +
fs.readFileSync(file('twemoji.tmp.js')).toString().replace(/("|')\u200D\1/g, '$1\\u200D$1')
fs.readFileSync(file('twemoji.tmp.js'))
);
fs.unlink(file('twemoji.tmp.js'));
// gzip -c twemoji.min.js | wc -c

View File

@ -647,6 +647,9 @@ function createTwemoji(re) {
// not JIT based, and old browsers / engines
UFE0Fg = /\uFE0F/g,
// avoid using a string literal like '\u200D' here because minifiers expand it inline
U200D = String.fromCharCode(0x200D),
// used to find HTML special chars in attributes
rescaper = /[&<>'"]/g,
@ -731,7 +734,7 @@ function createTwemoji(re) {
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
return toCodePoint(rawText.indexOf(U200D) < 0 ?
rawText.replace(UFE0Fg, '') :
rawText
);