From d8d0a4d15d7fe9bbd69a0ab4b52c1ef52ec58920 Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Wed, 2 Oct 2013 18:40:48 -0700 Subject: [PATCH] support stamping template into lightDOM instead of ShadowDOM when polymer-element has `lightdom` attribute (ref #222) --- src/instance/base.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/instance/base.js b/src/instance/base.js index 131975c5fe..957d52f3d5 100644 --- a/src/instance/base.js +++ b/src/instance/base.js @@ -36,10 +36,12 @@ this.takeAttributes(); // add event listeners this.addHostListeners(); - // guarantees that while preparing, any sub-elements will also be prepared + // guarantees that while preparing, any + // sub-elements are also prepared preparingElements++; // process declarative resources this.parseDeclarations(this.__proto__); + // decrement semaphore preparingElements--; // user entry point this.ready(); @@ -88,7 +90,14 @@ }, // parse input as needed, override for custom behavior parseDeclaration: function(elementElement) { - this.shadowFromTemplate(this.fetchTemplate(elementElement)); + var template = this.fetchTemplate(elementElement); + if (template) { + if (this.element.hasAttribute('lightdom')) { + this.lightFromTemplate(template); + } else { + this.shadowFromTemplate(template); + } + } }, // return a shadow-root template (if desired), override for custom behavior fetchTemplate: function(elementElement) { @@ -117,6 +126,22 @@ return root; } }, + // utility function that stamps a