Permalink
Browse files

renaming files to match filenaming pattern requested, updating apng test

  • Loading branch information...
1 parent fa5d138 commit 969f4ea1fe8a6dbc272b5db5a8aec03b27d0f4f4 @addyosmani addyosmani committed Nov 30, 2011
View
@@ -2,15 +2,25 @@
// http://en.wikipedia.org/wiki/APNG
// By Addy Osmani
-Modernizr.addTest('apng', function () {
- var canvas = document.createElement('canvas');
- if !! (typeof canvas.getContext == 'undefined') {
- var apngTest = new Image(),
- ctx = document.createElement('canvas').getContext('2d');
- apngTest.onload = function () {
- ctx.drawImage(apngTest, 0, 0);
- return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
+(function () {
+
+ var image = new Image(),
+ canvas = document.createElement('canvas'),
+ ctx = canvas.getContext('2d');
+
+ if (!(typeof canvas.getContext == 'undefined')) {
+
+ image.onerror = function () {
+ Modernizr.addTest('apng', false);
};
- apngTest.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg==";
+ image.onload = function () {
+ Modernizr.addTest('apng', function () {
+ ctx.drawImage(image, 0, 0);
+ return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
+ });
+ };
+
+ image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg==";
}
-});
+
+}());
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 969f4ea

Please sign in to comment.