Permalink
Browse files

Add parse handling for stray/unnecessary VS16s

  • Loading branch information...
n8downs committed Jul 10, 2018
1 parent 1bbd060 commit c9a665abb2f2bbea66013df9c545b387e64b2217
Showing with 38 additions and 10 deletions.
  1. +2 −2 2/scripts/generate
  2. +29 −1 2/test/test.js
  3. +2 −2 2/twemoji.amd.js
  4. +2 −2 2/twemoji.js
  5. +1 −1 2/twemoji.min.js
  6. +2 −2 2/twemoji.npm.js
@@ -836,7 +836,7 @@ function createTwemoji(re) {
iconId = grabTheRightIcon(rawText);
i = index + rawText.length;
src = options.callback(iconId, options);
if (src) {
if (iconId && src) {
img = new Image();
img.onerror = options.onerror;
img.setAttribute('draggable', 'false');
@@ -897,7 +897,7 @@ function createTwemoji(re) {
src = options.callback(iconId, options),
attrib,
attrname;
if (src) {
if (iconId && src) {
// recycle the match string replacing the emoji
// with its image counter part
ret = '<img '.concat(
@@ -534,7 +534,35 @@ wru.test([{
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',
test: function () {
wru.assert(
@@ -374,7 +374,7 @@ define(function () {
iconId = grabTheRightIcon(rawText);
i = index + rawText.length;
src = options.callback(iconId, options);
if (src) {
if (iconId && src) {
img = new Image();
img.onerror = options.onerror;
img.setAttribute('draggable', 'false');
@@ -435,7 +435,7 @@ define(function () {
src = options.callback(iconId, options),
attrib,
attrname;
if (src) {
if (iconId && src) {
// recycle the match string replacing the emoji
// with its image counter part
ret = '<img '.concat(
@@ -373,7 +373,7 @@ var twemoji = (function (
iconId = grabTheRightIcon(rawText);
i = index + rawText.length;
src = options.callback(iconId, options);
if (src) {
if (iconId && src) {
img = new Image();
img.onerror = options.onerror;
img.setAttribute('draggable', 'false');
@@ -434,7 +434,7 @@ var twemoji = (function (
src = options.callback(iconId, options),
attrib,
attrname;
if (src) {
if (iconId && src) {
// recycle the match string replacing the emoji
// with its image counter part
ret = '<img '.concat(

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -374,7 +374,7 @@ var twemoji = (function (
iconId = grabTheRightIcon(rawText);
i = index + rawText.length;
src = options.callback(iconId, options);
if (src) {
if (iconId && src) {
img = new Image();
img.onerror = options.onerror;
img.setAttribute('draggable', 'false');
@@ -435,7 +435,7 @@ var twemoji = (function (
src = options.callback(iconId, options),
attrib,
attrname;
if (src) {
if (iconId && src) {
// recycle the match string replacing the emoji
// with its image counter part
ret = '<img '.concat(

0 comments on commit c9a665a

Please sign in to comment.