Permalink
Browse files

added onerror option and test

  • Loading branch information...
WebReflection committed Nov 17, 2015
1 parent e436f75 commit f249ba9edd18dde6d9085d538f58a9644a9d180c
Showing with 35 additions and 13 deletions.
  1. +1 −1 package.json
  2. +18 −0 test.js
  3. +3 −2 twemoji-generator.js
  4. +4 −3 twemoji.amd.js
  5. +4 −3 twemoji.js
  6. +1 −1 twemoji.min.js
  7. +4 −3 twemoji.npm.js
View
@@ -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.",
View
18 test.js
@@ -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');
+ })});
+ }
}]);
View
@@ -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) {
@@ -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
});
}
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit f249ba9

Please sign in to comment.