Skip to content

Commit

Permalink
Fix tests on IE10 and simplify constructor shortcut.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Jan 26, 2017
1 parent 73b62a6 commit e588f1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/lib/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
// IFF `lazyRegister` is 'max'
if (settings.lazyRegister === 'max') {
proto._desugarBehaviors(); // abstract
for (var i=0, b; i < this.behaviors.length; i++) {
b = this.behaviors[i];
for (var i=0, b; i < proto.behaviors.length; i++) {
b = proto.behaviors[i];
if (b.beforeRegister) {
b.beforeRegister.call(proto);
}
Expand Down
20 changes: 11 additions & 9 deletions src/lib/polymer-bootstrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
prototype = {};
}
// desugar the prototype and return a factory object
var factory = desugar(prototype);
// Polymer.Base is now chained to factory.prototype, and for IE10 compat
// Polymer.Base is now chained to prototype, and for IE10 compat
// this may have resulted in a new prototype being created
//prototype = factory.prototype;
prototype = desugar(prototype);
// we have a custom constructor if the constructor's prototype
// is the prototype we're registering...
var customCtor = prototype === prototype.constructor.prototype ?
prototype.constructor : null;
var options = {
prototype: prototype
};
Expand All @@ -44,7 +47,7 @@
}
Polymer.telemetry._registrate(prototype);
var ctor = document.registerElement(prototype.is, options);
return factory.__custom ? factory : ctor;
return customCtor || ctor;
};

var desugar = function(prototype) {
Expand All @@ -56,11 +59,8 @@
base = Polymer.Base._getExtendedPrototype(prototype.extends);
}
prototype = Polymer.Base.chainObject(prototype, base);
var ctor = prototype.constructor;
prototype.registerCallback();
var custom = ctor !== prototype.constructor;
prototype.constructor.__custom = custom;
return prototype.constructor;
return prototype;
};

if (userPolymer) {
Expand All @@ -69,7 +69,9 @@
}
}

Polymer.Class = desugar;
Polymer.Class = function(prototype) {
return desugar(prototype).constructor;
}

})();

Expand Down

0 comments on commit e588f1f

Please sign in to comment.