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

Commit 4cc6fd4

Browse files
committed
Merge pull request #386 from arv/set-prototype
Set the prototype after all the mutations to allow optimizations
2 parents 73843e5 + b260574 commit 4cc6fd4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/wrappers.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ window.ShadowDOMPolyfill = {};
214214
enumerable: false,
215215
writable: true
216216
});
217+
// Set it again. Some VMs optimizes objects that are used as prototypes.
218+
wrapperConstructor.prototype = wrapperPrototype;
217219
}
218220

219221
function isWrapperFor(wrapperConstructor, nativeConstructor) {
@@ -241,9 +243,9 @@ window.ShadowDOMPolyfill = {};
241243
function GeneratedWrapper(node) {
242244
superWrapperConstructor.call(this, node);
243245
}
244-
GeneratedWrapper.prototype =
245-
Object.create(superWrapperConstructor.prototype);
246-
GeneratedWrapper.prototype.constructor = GeneratedWrapper;
246+
var p = Object.create(superWrapperConstructor.prototype);
247+
p.constructor = GeneratedWrapper;
248+
GeneratedWrapper.prototype = p;
247249

248250
return GeneratedWrapper;
249251
}

0 commit comments

Comments
 (0)