Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix: wrap Object.defineProperties
Browse files Browse the repository at this point in the history
Closes #24
  • Loading branch information
btford committed Jun 6, 2014
1 parent 383b479 commit f587f17
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/patch/registerElement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,30 @@ describe('document.registerElement', function () {
});
});


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);
});
});

});
7 changes: 7 additions & 0 deletions zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,13 @@ Zone.patchDefineProperty = function () {
return rewriteDescriptor(obj, prop, desc);
};

Object.defineProperties = function (obj, props) {
Object.keys(props).forEach(function (prop) {
Object.defineProperty(obj, prop, props[prop]);
});
return obj;
};

Object.getOwnPropertyDescriptor = function (obj, prop) {
var desc = _getOwnPropertyDescriptor(obj, prop);
if (isUnconfigurable(obj, prop)) {
Expand Down

0 comments on commit f587f17

Please sign in to comment.