[html5] r8066 - [e] (0) Fix a the createImageBitmap() example to use the Promise API more correc [...]

whatwg at whatwg.org whatwg at whatwg.org
Wed Jul 17 15:44:40 PDT 2013


Author: ianh
Date: 2013-07-17 15:44:39 -0700 (Wed, 17 Jul 2013)
New Revision: 8066

Modified:
   complete.html
   index
   source
Log:
[e] (0) Fix a the createImageBitmap() example to use the Promise API more correctly.
Affected topics: Canvas

Modified: complete.html
===================================================================
--- complete.html	2013-07-17 21:03:08 UTC (rev 8065)
+++ complete.html	2013-07-17 22:44:39 UTC (rev 8066)
@@ -75599,16 +75599,17 @@
 function loadMySprites() {
   var image = new Image();
   image.src = 'mysprites.png';
-  var promise = new Promise();
+  var resolver;
+  var promise = new Promise(function (arg) { resolver = arg });
   image.onload = function () {
-    Promise.every(
+    resolver.resolve(Promise.every(
       createImageBitmap(image,  0,  0, 40, 40).then(function (image) { sprites.woman = image }),
       createImageBitmap(image, 40,  0, 40, 40).then(function (image) { sprites.man   = image }),
       createImageBitmap(image, 80,  0, 40, 40).then(function (image) { sprites.tree  = image }),
       createImageBitmap(image,  0, 40, 40, 40).then(function (image) { sprites.hut   = image }),
       createImageBitmap(image, 40, 40, 40, 40).then(function (image) { sprites.apple = image }),
       createImageBitmap(image, 80, 40, 40, 40).then(function (image) { sprites.snake = image }),
-    ).then(function (value) { promise.fulfill(value) }, function (value) { promise.reject(value) } );
+    ));
   };
   return promise;
 }

Modified: index
===================================================================
--- index	2013-07-17 21:03:08 UTC (rev 8065)
+++ index	2013-07-17 22:44:39 UTC (rev 8066)
@@ -75599,16 +75599,17 @@
 function loadMySprites() {
   var image = new Image();
   image.src = 'mysprites.png';
-  var promise = new Promise();
+  var resolver;
+  var promise = new Promise(function (arg) { resolver = arg });
   image.onload = function () {
-    Promise.every(
+    resolver.resolve(Promise.every(
       createImageBitmap(image,  0,  0, 40, 40).then(function (image) { sprites.woman = image }),
       createImageBitmap(image, 40,  0, 40, 40).then(function (image) { sprites.man   = image }),
       createImageBitmap(image, 80,  0, 40, 40).then(function (image) { sprites.tree  = image }),
       createImageBitmap(image,  0, 40, 40, 40).then(function (image) { sprites.hut   = image }),
       createImageBitmap(image, 40, 40, 40, 40).then(function (image) { sprites.apple = image }),
       createImageBitmap(image, 80, 40, 40, 40).then(function (image) { sprites.snake = image }),
-    ).then(function (value) { promise.fulfill(value) }, function (value) { promise.reject(value) } );
+    ));
   };
   return promise;
 }

Modified: source
===================================================================
--- source	2013-07-17 21:03:08 UTC (rev 8065)
+++ source	2013-07-17 22:44:39 UTC (rev 8066)
@@ -84679,16 +84679,17 @@
 function loadMySprites() {
   var image = new Image();
   image.src = 'mysprites.png';
-  var promise = new Promise();
+  var resolver;
+  var promise = new Promise(function (arg) { resolver = arg });
   image.onload = function () {
-    Promise.every(
+    resolver.resolve(Promise.every(
       createImageBitmap(image,  0,  0, 40, 40).then(function (image) { sprites.woman = image }),
       createImageBitmap(image, 40,  0, 40, 40).then(function (image) { sprites.man   = image }),
       createImageBitmap(image, 80,  0, 40, 40).then(function (image) { sprites.tree  = image }),
       createImageBitmap(image,  0, 40, 40, 40).then(function (image) { sprites.hut   = image }),
       createImageBitmap(image, 40, 40, 40, 40).then(function (image) { sprites.apple = image }),
       createImageBitmap(image, 80, 40, 40, 40).then(function (image) { sprites.snake = image }),
-    ).then(function (value) { promise.fulfill(value) }, function (value) { promise.reject(value) } );
+    ));
   };
   return promise;
 }




More information about the Commit-Watchers mailing list