From e269582047fb4d384a48c9890906bf06742a932b Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Thu, 14 Nov 2013 11:15:33 -0800 Subject: [PATCH] Fixes #347. --- src/declaration/polymer-element.js | 5 +++-- src/declaration/prototype.js | 20 +++++++++++++++++--- test/html/element-registration.html | 10 ++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/declaration/polymer-element.js b/src/declaration/polymer-element.js index 482c030..076a984 100644 --- a/src/declaration/polymer-element.js +++ b/src/declaration/polymer-element.js @@ -27,6 +27,8 @@ createdCallback: function() { // fetch the element name this.name = this.getAttribute('name'); + // fetch our extendee name + this.extends = this.getAttribute('extends'); // install element definition, if ready this.registerWhenReady(); }, @@ -35,8 +37,7 @@ if (this.waitingForPrototype(this.name)) { return; } - // fetch our extendee name - var extendee = this.getAttribute('extends'); + var extendee = this.extends; if (this.waitingForExtendee(extendee)) { //console.warn(this.name + ': waitingForExtendee:' + extendee); return; diff --git a/src/declaration/prototype.js b/src/declaration/prototype.js index 4b7c9b9..8d5b4e7 100644 --- a/src/declaration/prototype.js +++ b/src/declaration/prototype.js @@ -114,7 +114,7 @@ }, // build prototype combining extendee, Polymer base, and named api generateBasePrototype: function(extnds) { - var prototype = memoizedBases[extnds]; + var prototype = this.findBasePrototype(extnds); if (!prototype) { // create a prototype based on tag-name extension var prototype = HTMLElement.getPrototypeForTag(extnds); @@ -125,6 +125,9 @@ } return prototype; }, + findBasePrototype: function(name) { + return memoizedBases[name]; + }, // install Polymer instance api into prototype chain, as needed ensureBaseApi: function(prototype) { if (!prototype.PolymerBase) { @@ -153,8 +156,9 @@ prototype: this.prototype } // native element must be specified in extends - if (extendee && extendee.indexOf('-') < 0) { - info.extends = extendee; + var typeExtension = this.findTypeExtension(extendee); + if (typeExtension) { + info.extends = typeExtension; } // register the custom type this.ctor = document.register(name, info); @@ -162,6 +166,16 @@ this.prototype.constructor = this.ctor; // register the prototype with HTMLElement for name lookup HTMLElement.register(name, this.prototype); + }, + findTypeExtension: function(name) { + if (name && name.indexOf('-') < 0) { + return name; + } else { + var p = this.findBasePrototype(name); + if (p.element) { + return this.findTypeExtension(p.element.extends); + } + } } }; diff --git a/test/html/element-registration.html b/test/html/element-registration.html index bfb4396..9cfd683 100644 --- a/test/html/element-registration.html +++ b/test/html/element-registration.html @@ -31,6 +31,8 @@
  • +
    +
  • @@ -140,6 +142,12 @@ + + + +