From e588f1f57a1b9cf3aa341ad045db56bac7427a46 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 26 Jan 2017 10:48:56 -0800 Subject: [PATCH] Fix tests on IE10 and simplify constructor shortcut. --- src/lib/base.html | 4 ++-- src/lib/polymer-bootstrap.html | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/lib/base.html b/src/lib/base.html index 215ef93782..4f557b9eb2 100644 --- a/src/lib/base.html +++ b/src/lib/base.html @@ -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); } diff --git a/src/lib/polymer-bootstrap.html b/src/lib/polymer-bootstrap.html index c74119327a..ef9c332902 100644 --- a/src/lib/polymer-bootstrap.html +++ b/src/lib/polymer-bootstrap.html @@ -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 }; @@ -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) { @@ -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) { @@ -69,7 +69,9 @@ } } - Polymer.Class = desugar; + Polymer.Class = function(prototype) { + return desugar(prototype).constructor; + } })();