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

Commit

Permalink
Ensure we have a __proto__ chain on platforms that don't natively sup…
Browse files Browse the repository at this point in the history
…port __proto__ (IE10).

This helps address Polymer/polymer#217
  • Loading branch information
sorvell committed Jul 30, 2013
1 parent 948b53c commit 9b4c5df
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/CustomElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@ function resolvePrototypeChain(inDefinition) {
var inst = document.createElement(inDefinition.tag);
native = Object.getPrototypeOf(inst);
}
// ensure __proto__ reference is installed at each point on the prototype
// chain.
// NOTE: On platforms without __proto__, a mixin strategy is used instead
// of prototype swizzling. In this case, this generated __proto__ provides
// limited support for prototype traversal.
var proto = inDefinition.prototype, ancestor;
while (proto && (proto !== native)) {
var ancestor = Object.getPrototypeOf(proto);
proto.__proto__ = ancestor;
proto = ancestor;
}
}
// cache this in case of mixin
inDefinition.native = native;
Expand Down

0 comments on commit 9b4c5df

Please sign in to comment.