Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Set the prototype after all the mutations to allow optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Feb 27, 2014
1 parent 7578669 commit b260574
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ window.ShadowDOMPolyfill = {};
enumerable: false,
writable: true
});
// Set it again. Some VMs optimizes objects that are used as prototypes.
wrapperConstructor.prototype = wrapperPrototype;
}

function isWrapperFor(wrapperConstructor, nativeConstructor) {
Expand Down Expand Up @@ -241,9 +243,9 @@ window.ShadowDOMPolyfill = {};
function GeneratedWrapper(node) {
superWrapperConstructor.call(this, node);
}
GeneratedWrapper.prototype =
Object.create(superWrapperConstructor.prototype);
GeneratedWrapper.prototype.constructor = GeneratedWrapper;
var p = Object.create(superWrapperConstructor.prototype);
p.constructor = GeneratedWrapper;
GeneratedWrapper.prototype = p;

return GeneratedWrapper;
}
Expand Down

0 comments on commit b260574

Please sign in to comment.