mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
Add parse handling for stray/unnecessary VS16s
This commit is contained in:
parent
1bbd06079e
commit
c9a665abb2
@ -836,7 +836,7 @@ function createTwemoji(re) {
|
|||||||
iconId = grabTheRightIcon(rawText);
|
iconId = grabTheRightIcon(rawText);
|
||||||
i = index + rawText.length;
|
i = index + rawText.length;
|
||||||
src = options.callback(iconId, options);
|
src = options.callback(iconId, options);
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
img = new Image();
|
img = new Image();
|
||||||
img.onerror = options.onerror;
|
img.onerror = options.onerror;
|
||||||
img.setAttribute('draggable', 'false');
|
img.setAttribute('draggable', 'false');
|
||||||
@ -897,7 +897,7 @@ function createTwemoji(re) {
|
|||||||
src = options.callback(iconId, options),
|
src = options.callback(iconId, options),
|
||||||
attrib,
|
attrib,
|
||||||
attrname;
|
attrname;
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
// recycle the match string replacing the emoji
|
// recycle the match string replacing the emoji
|
||||||
// with its image counter part
|
// with its image counter part
|
||||||
ret = '<img '.concat(
|
ret = '<img '.concat(
|
||||||
|
@ -534,7 +534,35 @@ wru.test([{
|
|||||||
div.firstChild.src === 'https://twemoji.maxcdn.com/2/72x72/2639.png'
|
div.firstChild.src === 'https://twemoji.maxcdn.com/2/72x72/2639.png'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, {
|
},{
|
||||||
|
name: 'lone vs16s',
|
||||||
|
test: function () {
|
||||||
|
wru.assert('are not parsed in strings',
|
||||||
|
twemoji.parse('\ufe0f') === '\ufe0f'
|
||||||
|
);
|
||||||
|
|
||||||
|
var div = document.createElement('div');
|
||||||
|
div.innerHTML = '\ufe0f';
|
||||||
|
twemoji.parse(div);
|
||||||
|
wru.assert('are not parsed in nodes',
|
||||||
|
div.innerHTML === '\ufe0f'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
name: 'unnecessary vs16s',
|
||||||
|
test: function () {
|
||||||
|
wru.assert('are not parsed in strings',
|
||||||
|
twemoji.parse('\ud83d\ude10\ufe0f') === '<img class="emoji" draggable="false" alt="\ud83d\ude10" src="https://twemoji.maxcdn.com/2/72x72/1f610.png"/>\ufe0f'
|
||||||
|
);
|
||||||
|
|
||||||
|
var div = document.createElement('div');
|
||||||
|
div.innerHTML = '\ud83d\ude10\ufe0f';
|
||||||
|
twemoji.parse(div);
|
||||||
|
wru.assert('are not parsed in nodes',
|
||||||
|
div.children.length === 1 && div.innerText === '\ufe0f'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},{
|
||||||
name: 'multiple parsing using a callback',
|
name: 'multiple parsing using a callback',
|
||||||
test: function () {
|
test: function () {
|
||||||
wru.assert(
|
wru.assert(
|
||||||
|
@ -374,7 +374,7 @@ define(function () {
|
|||||||
iconId = grabTheRightIcon(rawText);
|
iconId = grabTheRightIcon(rawText);
|
||||||
i = index + rawText.length;
|
i = index + rawText.length;
|
||||||
src = options.callback(iconId, options);
|
src = options.callback(iconId, options);
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
img = new Image();
|
img = new Image();
|
||||||
img.onerror = options.onerror;
|
img.onerror = options.onerror;
|
||||||
img.setAttribute('draggable', 'false');
|
img.setAttribute('draggable', 'false');
|
||||||
@ -435,7 +435,7 @@ define(function () {
|
|||||||
src = options.callback(iconId, options),
|
src = options.callback(iconId, options),
|
||||||
attrib,
|
attrib,
|
||||||
attrname;
|
attrname;
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
// recycle the match string replacing the emoji
|
// recycle the match string replacing the emoji
|
||||||
// with its image counter part
|
// with its image counter part
|
||||||
ret = '<img '.concat(
|
ret = '<img '.concat(
|
||||||
|
@ -373,7 +373,7 @@ var twemoji = (function (
|
|||||||
iconId = grabTheRightIcon(rawText);
|
iconId = grabTheRightIcon(rawText);
|
||||||
i = index + rawText.length;
|
i = index + rawText.length;
|
||||||
src = options.callback(iconId, options);
|
src = options.callback(iconId, options);
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
img = new Image();
|
img = new Image();
|
||||||
img.onerror = options.onerror;
|
img.onerror = options.onerror;
|
||||||
img.setAttribute('draggable', 'false');
|
img.setAttribute('draggable', 'false');
|
||||||
@ -434,7 +434,7 @@ var twemoji = (function (
|
|||||||
src = options.callback(iconId, options),
|
src = options.callback(iconId, options),
|
||||||
attrib,
|
attrib,
|
||||||
attrname;
|
attrname;
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
// recycle the match string replacing the emoji
|
// recycle the match string replacing the emoji
|
||||||
// with its image counter part
|
// with its image counter part
|
||||||
ret = '<img '.concat(
|
ret = '<img '.concat(
|
||||||
|
2
2/twemoji.min.js
vendored
2
2/twemoji.min.js
vendored
File diff suppressed because one or more lines are too long
@ -374,7 +374,7 @@ var twemoji = (function (
|
|||||||
iconId = grabTheRightIcon(rawText);
|
iconId = grabTheRightIcon(rawText);
|
||||||
i = index + rawText.length;
|
i = index + rawText.length;
|
||||||
src = options.callback(iconId, options);
|
src = options.callback(iconId, options);
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
img = new Image();
|
img = new Image();
|
||||||
img.onerror = options.onerror;
|
img.onerror = options.onerror;
|
||||||
img.setAttribute('draggable', 'false');
|
img.setAttribute('draggable', 'false');
|
||||||
@ -435,7 +435,7 @@ var twemoji = (function (
|
|||||||
src = options.callback(iconId, options),
|
src = options.callback(iconId, options),
|
||||||
attrib,
|
attrib,
|
||||||
attrname;
|
attrname;
|
||||||
if (src) {
|
if (iconId && src) {
|
||||||
// recycle the match string replacing the emoji
|
// recycle the match string replacing the emoji
|
||||||
// with its image counter part
|
// with its image counter part
|
||||||
ret = '<img '.concat(
|
ret = '<img '.concat(
|
||||||
|
Loading…
Reference in New Issue
Block a user