diff --git a/src/js/model/Frame.js b/src/js/model/Frame.js index 3e692fe4..89ec6335 100644 --- a/src/js/model/Frame.js +++ b/src/js/model/Frame.js @@ -58,13 +58,7 @@ } else { pixels = _emptyPixelGridCache[key] = new Uint32Array(width * height); var transparentColorInt = pskl.utils.colorToInt(Constants.TRANSPARENT_COLOR); - if (!pixels.fill) { // PhantomJS ='( - for (var i = 0; i < width * height; i++) { - pixels[i] = transparentColorInt; - } - } else { - pixels.fill(transparentColorInt); - } + pixels.fill(transparentColorInt); } return new Uint32Array(pixels); diff --git a/src/js/utils/core.js b/src/js/utils/core.js index 458d9543..cf5b0ed6 100644 --- a/src/js/utils/core.js +++ b/src/js/utils/core.js @@ -38,6 +38,28 @@ if (!Function.prototype.bind) { }; } +/** + * Polyfill for typedarrays' fill method for PhantomJS + */ +if (!Uint32Array.prototype.fill) { + Uint32Array.prototype.fill = function (value, start, end) { + start = typeof start === 'undefined' ? 0 : start; + end = typeof end === 'undefined' ? this.length : end; + + if (start < 0) { + start = this.length + start; + } + + if (end < 0) { + end = this.length + end; + } + + for (var i = start; i < end; i++) { + this[i] = value; + } + }; +} + /** * @provide pskl.utils *