Skip to content

Commit

Permalink
added onerror option and test
Browse files Browse the repository at this point in the history
  • Loading branch information
WebReflection committed Nov 17, 2015
1 parent e436f75 commit f249ba9
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,5 +1,5 @@
{
"version": "1.4.1",
"version": "1.4.2",
"name": "twemoji",
"license": ["MIT", "CC-BY-4.0"],
"description": "A Unicode standard based way to implement emoji across all platforms.",
Expand Down
18 changes: 18 additions & 0 deletions test.js
Expand Up @@ -535,4 +535,22 @@ wru.test([{
wru.assert('nothing to do here');
}
}
}, {
name: 'using a different onerror',
test: function () {
var Image = window.Image;
window.Image = function () {
var self = new Image;
setTimeout(function () {
window.Image = Image;
self.onerror();
}, 10);
return self;
};
var div = document.createElement('div');
div.innerHTML = '5\ufe0f\u20e3';
twemoji.parse(div, {onerror: wru.async(function () {
wru.assert('OK');
})});
}
}]);
5 changes: 3 additions & 2 deletions twemoji-generator.js
Expand Up @@ -664,7 +664,7 @@ function createTwemoji(re) {
);
if (src) {
img = new Image();
img.onerror = twemoji.onerror;
img.onerror = options.onerror;
img.setAttribute('draggable', 'false');
attrib = options.attributes(icon, variant);
for (attrname in attrib) {
Expand Down Expand Up @@ -828,7 +828,8 @@ function createTwemoji(re) {
base: typeof how.base === 'string' ? how.base : twemoji.base,
ext: how.ext || twemoji.ext,
size: how.folder || toSizeSquaredAsset(how.size || twemoji.size),
className: how.className || twemoji.className
className: how.className || twemoji.className,
onerror: how.onerror || twemoji.onerror
});
}

Expand Down
7 changes: 4 additions & 3 deletions twemoji.amd.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions twemoji.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion twemoji.min.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions twemoji.npm.js

Large diffs are not rendered by default.

0 comments on commit f249ba9

Please sign in to comment.