Socket
Socket
Sign inDemoInstall

zone.js

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zone.js - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

test/assets/import.html

6

karma.conf.js

@@ -9,3 +9,5 @@ // Karma configuration

'*-zone.js',
'test/**/*.spec.js'
'test/lib/brick.js',
'test/**/*.spec.js',
{pattern: 'test/assets/**/*.html', watched: true, served: true, included: false}
],

@@ -15,2 +17,4 @@

preprocessors: {},
port: 9876,

@@ -17,0 +21,0 @@ colors: true,

2

package.json
{
"name": "zone.js",
"version": "0.2.4",
"version": "0.3.0",
"description": "Zones for JavaScript",

@@ -5,0 +5,0 @@ "main": "zone.js",

@@ -109,2 +109,52 @@ /*

it('should work with prototypes that have non-writable, non-configurable descriptors', function () {
runs(function () {
var proto = Object.create(HTMLElement.prototype);
Object.defineProperty(proto, 'createdCallback', {
writeable: false,
configurable: false,
value: flagAndCheckZone
});
document.registerElement('x-prop-desc', {
prototype: proto
});
var elt = document.createElement('x-prop-desc');
});
waitsFor(function() {
return flag;
}, 'createdCallback to fire', 100);
runs(function() {
expect(hasParent).toBe(true);
});
});
it('should work with prototypes that have non-writable, non-configurable descriptors', function () {
runs(function () {
var proto = Object.create(HTMLElement.prototype);
Object.defineProperties(proto, {
createdCallback: {
writeable: false,
configurable: false,
value: flagAndCheckZone
}
});
document.registerElement('x-props-desc', {
prototype: proto
});
var elt = document.createElement('x-props-desc');
});
waitsFor(function() {
return flag;
}, 'createdCallback to fire', 100);
runs(function() {
expect(hasParent).toBe(true);
});
});
});

@@ -54,2 +54,53 @@ 'use strict';

describe('mozRequestAnimationFrame', function () {
var flag, hasParent, skip = false;
it('should work', function (done) {
if (!window.mozRequestAnimationFrame) {
console.log('WARNING: skipping mozRequestAnimationFrame test (missing this API)');
return;
}
// Some browsers (especially Safari) do not fire mozRequestAnimationFrame
// if they are offscreen. We can disable this test for those browsers and
// assume the patch works if setTimeout works, since they are mechanically
// the same
runs(function() {
flag = false;
window.mozRequestAnimationFrame(function () {
flag = true;
});
setTimeout(function () {
skip = true;
flag = true;
console.log('WARNING: skipping mozRequestAnimationFrame test (not firing rAF)');
}, 50);
});
waitsFor(function() {
return flag;
}, 'mozRequestAnimationFrame to run', 100);
runs(function() {
flag = false;
hasParent = false;
window.mozRequestAnimationFrame(function () {
hasParent = !!window.zone.parent;
flag = true;
});
});
waitsFor(function() {
return flag || skip;
}, 'mozRequestAnimationFrame to run', 100);
runs(function() {
expect(hasParent || skip).toBe(true);
});
});
});
describe('webkitRequestAnimationFrame', function () {

@@ -104,2 +155,2 @@ var flag, hasParent, skip = false;

});
});
});

@@ -69,5 +69,6 @@ 'use strict';

bindOnce: function (fn) {
var boundZone = this;
return this.bind(function () {
var result = fn.apply(this, arguments);
zone.dequeueTask(fn);
boundZone.dequeueTask(fn);
return result;

@@ -313,2 +314,3 @@ });

'requestAnimationFrame',
'mozRequestAnimationFrame',
'webkitRequestAnimationFrame'

@@ -371,2 +373,3 @@ ]);

Zone.patchMutationObserverClass('WebKitMutationObserver');
Zone.patchDefineProperty();
Zone.patchRegisterElement();

@@ -516,2 +519,64 @@ };

// might need similar for object.freeze
// i regret nothing
Zone.patchDefineProperty = function () {
var _defineProperty = Object.defineProperty;
var _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var _create = Object.create;
Object.defineProperty = function (obj, prop, desc) {
if (isUnconfigurable(obj, prop)) {
throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj);
}
if (prop !== 'prototype') {
desc = rewriteDescriptor(obj, prop, desc);
}
return _defineProperty(obj, prop, desc);
};
Object.defineProperties = function (obj, props) {
Object.keys(props).forEach(function (prop) {
Object.defineProperty(obj, prop, props[prop]);
});
return obj;
};
Object.create = function (obj, proto) {
if (typeof proto === 'object') {
Object.keys(proto).forEach(function (prop) {
proto[prop] = rewriteDescriptor(obj, prop, proto[prop]);
});
}
return _create(obj, proto);
};
Object.getOwnPropertyDescriptor = function (obj, prop) {
var desc = _getOwnPropertyDescriptor(obj, prop);
if (isUnconfigurable(obj, prop)) {
desc.configurable = false;
}
return desc;
};
Zone._redefineProperty = function (obj, prop, desc) {
desc = rewriteDescriptor(obj, prop, desc);
return _defineProperty(obj, prop, desc);
};
function isUnconfigurable (obj, prop) {
return obj && obj.__unconfigurables && obj.__unconfigurables[prop];
}
function rewriteDescriptor (obj, prop, desc) {
desc.configurable = true;
if (!desc.configurable) {
if (!obj.__unconfigurables) {
_defineProperty(obj, '__unconfigurables', { writable: true, value: {} });
}
obj.__unconfigurables[prop] = true;
}
return desc;
}
};
Zone.patchRegisterElement = function () {

@@ -531,3 +596,7 @@ if (!('registerElement' in document)) {

if (opts.prototype[callback]) {
opts.prototype[callback] = zone.bind(opts.prototype[callback]);
var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback);
if (descriptor.value) {
descriptor.value = zone.bind(descriptor.value || opts.prototype[callback]);
Zone._redefineProperty(opts.prototype, callback, descriptor);
}
}

@@ -539,3 +608,3 @@ });

Zone.eventNames = 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error'.split(' ');
Zone.eventNames = 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror'.split(' ');
Zone.onEventNames = Zone.eventNames.map(function (property) {

@@ -542,0 +611,0 @@ return 'on' + property;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc