1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-07-03 03:18:58 +00:00

Alternate way to avoid using \u 200d

This commit is contained in:
Tom Wuttke 2016-03-02 06:34:50 -08:00
parent 7d3de547c0
commit ba0f4e7847
6 changed files with 10 additions and 6 deletions

View File

@ -316,7 +316,8 @@ define(function () {
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
// (avoid using a string literal for '\u200D' or minifiers may inject the raw value)
return toCodePoint(rawText.indexOf(String.fromCharCode(0x200D)) < 0 ?
rawText.replace(UFE0Fg, '') :
rawText
);

View File

@ -315,7 +315,8 @@ var twemoji = (function (
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
// (avoid using a string literal for '\u200D' or minifiers may inject the raw value)
return toCodePoint(rawText.indexOf(String.fromCharCode(0x200D)) < 0 ?
rawText.replace(UFE0Fg, '') :
rawText
);

2
2/twemoji.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -316,7 +316,8 @@ var twemoji = (function (
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
// (avoid using a string literal for '\u200D' or minifiers may inject the raw value)
return toCodePoint(rawText.indexOf(String.fromCharCode(0x200D)) < 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

@ -731,7 +731,8 @@ function createTwemoji(re) {
*/
function grabTheRightIcon(rawText) {
// if variant is present as \uFE0F
return toCodePoint(rawText.indexOf('\u200D') < 0 ?
// (avoid using a string literal for '\u200D' or minifiers may inject the raw value)
return toCodePoint(rawText.indexOf(String.fromCharCode(0x200D)) < 0 ?
rawText.replace(UFE0Fg, '') :
rawText
);