From 58d2dc094058c7add229d4e83accb1e04860f1f5 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Tue, 23 Jul 2019 07:58:14 -0500 Subject: [PATCH] Fix template issue --- build/document-register-element.amd.js | 2 +- build/document-register-element.esm.js | 10 +++++-- build/document-register-element.js | 2 +- build/document-register-element.max.amd.js | 10 +++++-- build/document-register-element.max.js | 10 +++++-- build/document-register-element.node.js | 10 +++++-- pony/index.js | 10 +++++-- pony/index.mjs | 10 +++++-- src/document-register-element.js | 10 +++++-- test/template.html | 33 ++++++++++++++++++++++ 10 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 test/template.html diff --git a/build/document-register-element.amd.js b/build/document-register-element.amd.js index 077d228..cacebb0 100644 --- a/build/document-register-element.amd.js +++ b/build/document-register-element.amd.js @@ -1,2 +1,2 @@ /*! (C) Andrea Giammarchi - @WebReflection - ISC Style License */ -define(function(e){"use strict";function t(){var e=C.splice(0,C.length);for(We=0;e.length;)e.shift().call(null,e.shift())}function n(e,t){for(var n=0,r=e.length;n1)&&v(this)}}}),Re(l,B,{value:function(e){-1>0),U="addEventListener",_="attached",k="Callback",x="detached",q="extends",B="attributeChanged"+k,Z=_+k,j="connected"+k,G="disconnected"+k,z="created"+k,K=x+k,X="ADDITION",$="REMOVAL",Q="DOMAttrModified",W="DOMContentLoaded",Y="DOMSubtreeModified",J="<",ee="=",te=/^[A-Z][._A-Z0-9]*-[-._A-Z0-9]*$/,ne=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],re=[],oe=[],le="",ae=g.documentElement,ie=re.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},ue=b.prototype,ce=ue.hasOwnProperty,se=ue.isPrototypeOf,me=b.defineProperty,de=[],fe=b.getOwnPropertyDescriptor,pe=b.getOwnPropertyNames,he=b.getPrototypeOf,Te=b.setPrototypeOf,Le=!!b.__proto__,Me=!1,Ee="__dreCEv1",ve=window.customElements,He=!/^force/.test(e.type)&&!!(ve&&ve.define&&ve.get&&ve.whenDefined),we=b.create||b,ge=window.Map||function(){var e,t=[],n=[];return{get:function(e){return n[ie.call(t,e)]},set:function(r,o){e=ie.call(t,r),e<0?n[t.push(r)-1]=o:n[e]=o}}},be=window.Promise||function(e){function t(e){for(r=!0;n.length;)n.shift()(e)}var n=[],r=!1,o={"catch":function(){return o},then:function(e){return n.push(e),r&&setTimeout(t,1),o}};return e(t),o},ye=!1,Ce=we(null),Ae=we(null),Oe=new ge,Ne=function(e){return e.toLowerCase()},De=b.create||function at(e){return e?(at.prototype=e,new at):this},Ie=Te||(Le?function(e,t){return e.__proto__=t,e}:pe&&fe?function(){function e(e,t){for(var n,r=pe(t),o=0,l=r.length;o
",new Fe(function(e,t){if(e[0]&&"childList"==e[0].type&&!e[0].removedNodes[0].childNodes.length){V=fe(Ve,"innerHTML");var n=V&&V.set;n&&me(Ve,"innerHTML",{set:function(e){for(;this.lastChild;)this.removeChild(this.lastChild);n.call(this,e)}})}t.disconnect(),V=null}).observe(V,{childList:!0,subtree:!0}),V.innerHTML=""),Ye||(Te||Le?(F=function(e,t){se.call(t,e)||d(e,t)},S=d):(F=function(e,t){e[R]||(e[R]=b(!0),d(e,t))},S=F),Pe?(tt=!1,function(){var e=fe(Ve,U),t=e.value,n=function(e){var t=new CustomEvent(Q,{bubbles:!0});t.attrName=e,t.prevValue=Be.call(this,e),t.newValue=null,t[$]=t.attrChange=2,je.call(this,e),qe.call(this,t)},r=function(e,t){var n=Ze.call(this,e),r=n&&Be.call(this,e),o=new CustomEvent(Q,{bubbles:!0});Ge.call(this,e,t),o.attrName=e,o.prevValue=n?r:null,o.newValue=t,n?o.MODIFICATION=o.attrChange=1:o[X]=o.attrChange=0,qe.call(this,o)},o=function(e){var t,n=e.currentTarget,r=n[R],o=e.propertyName;r.hasOwnProperty(o)&&(r=r[o],t=new CustomEvent(Q,{bubbles:!0}),t.attrName=r.name,t.prevValue=r.value||null,t.newValue=r.value=n[o]||null,null==t.prevValue?t[X]=t.attrChange=0:t.MODIFICATION=t.attrChange=1,qe.call(n,t))};e.value=function(e,l,a){e===Q&&this[B]&&this.setAttribute!==r&&(this[R]={className:{name:"class",value:this.className}},this.setAttribute=r,this.removeAttribute=n,t.call(this,"propertychange",o)),t.call(this,e,l,a)},me(Ve,U,e)}()):Fe||(ae[U](Q,Qe),ae.setAttribute(R,1),ae.removeAttribute(R),tt&&(A=function(e){var t,n,r,o=this;if(o===e.target){t=o[R],o[R]=n=N(o);for(r in n){if(!(r in t))return O(0,o,r,t[r],n[r],X);if(n[r]!==t[r])return O(1,o,r,t[r],n[r],"MODIFICATION")}for(r in t)if(!(r in n))return O(2,o,r,t[r],n[r],$)}},O=function(e,t,n,r,o,l){var a={attrChange:e,currentTarget:t,attrName:n,prevValue:r,newValue:o};a[l]=e,i(a)},N=function(e){for(var t,n,r={},o=e.attributes,l=0,a=o.length;l$");if(t[q]="a",e.prototype=De(Se.prototype),e.prototype.constructor=e,window.customElements.define(n,e,t),!r.test(g.createElement("a",{is:n}).outerHTML)||!r.test((new e).outerHTML))throw t}(function it(){return Reflect.construct(Se,[],it)},{},"document-register-element-a")}catch(ot){w()}if(!e.noBuiltIn)try{if(ze.call(g,"a","a").outerHTML.indexOf("is")<0)throw{}}catch(lt){Ne=function(e){return{is:e.toLowerCase()}}}}); +define(function(e){"use strict";function t(){var e=C.splice(0,C.length);for(Ye=0;e.length;)e.shift().call(null,e.shift())}function n(e,t){for(var n=0,r=e.length;n1)&&v(this)}}}),Re(l,B,{value:function(e){-1>0),U="addEventListener",_="attached",k="Callback",x="detached",q="extends",B="attributeChanged"+k,Z=_+k,j="connected"+k,G="disconnected"+k,z="created"+k,K=x+k,X="ADDITION",$="REMOVAL",Q="DOMAttrModified",W="DOMContentLoaded",Y="DOMSubtreeModified",J="<",ee="=",te=/^[A-Z][._A-Z0-9]*-[-._A-Z0-9]*$/,ne=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],re=[],oe=[],le="",ae=g.documentElement,ie=re.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},ue=b.prototype,ce=ue.hasOwnProperty,se=ue.isPrototypeOf,me=b.defineProperty,de=[],fe=b.getOwnPropertyDescriptor,pe=b.getOwnPropertyNames,he=b.getPrototypeOf,Te=b.setPrototypeOf,Le=!!b.__proto__,Me=!1,Ee="__dreCEv1",ve=window.customElements,He=!/^force/.test(e.type)&&!!(ve&&ve.define&&ve.get&&ve.whenDefined),we=b.create||b,ge=window.Map||function(){var e,t=[],n=[];return{get:function(e){return n[ie.call(t,e)]},set:function(r,o){e=ie.call(t,r),e<0?n[t.push(r)-1]=o:n[e]=o}}},be=window.Promise||function(e){function t(e){for(r=!0;n.length;)n.shift()(e)}var n=[],r=!1,o={"catch":function(){return o},then:function(e){return n.push(e),r&&setTimeout(t,1),o}};return e(t),o},ye=!1,Ce=we(null),Ae=we(null),Oe=new ge,Ne=function(e){return e.toLowerCase()},De=b.create||function it(e){return e?(it.prototype=e,new it):this},Ie=Te||(Le?function(e,t){return e.__proto__=t,e}:pe&&fe?function(){function e(e,t){for(var n,r=pe(t),o=0,l=r.length;o
",new Fe(function(e,t){if(e[0]&&"childList"==e[0].type&&!e[0].removedNodes[0].childNodes.length){V=fe(Ve,"innerHTML");var n=V&&V.set;n&&me(Ve,"innerHTML",{set:function(e){for(;this.lastChild;)this.removeChild(this.lastChild);n.call(this,e)}})}t.disconnect(),V=null}).observe(V,{childList:!0,subtree:!0}),V.innerHTML=""),Je||(Te||Le?(F=function(e,t){se.call(t,e)||d(e,t)},S=d):(F=function(e,t){e[R]||(e[R]=b(!0),d(e,t))},S=F),Pe?(nt=!1,function(){var e=fe(Ve,U),t=e.value,n=function(e){var t=new CustomEvent(Q,{bubbles:!0});t.attrName=e,t.prevValue=Ze.call(this,e),t.newValue=null,t[$]=t.attrChange=2,Ge.call(this,e),Be.call(this,t)},r=function(e,t){var n=je.call(this,e),r=n&&Ze.call(this,e),o=new CustomEvent(Q,{bubbles:!0});ze.call(this,e,t),o.attrName=e,o.prevValue=n?r:null,o.newValue=t,n?o.MODIFICATION=o.attrChange=1:o[X]=o.attrChange=0,Be.call(this,o)},o=function(e){var t,n=e.currentTarget,r=n[R],o=e.propertyName;r.hasOwnProperty(o)&&(r=r[o],t=new CustomEvent(Q,{bubbles:!0}),t.attrName=r.name,t.prevValue=r.value||null,t.newValue=r.value=n[o]||null,null==t.prevValue?t[X]=t.attrChange=0:t.MODIFICATION=t.attrChange=1,Be.call(n,t))};e.value=function(e,l,a){e===Q&&this[B]&&this.setAttribute!==r&&(this[R]={className:{name:"class",value:this.className}},this.setAttribute=r,this.removeAttribute=n,t.call(this,"propertychange",o)),t.call(this,e,l,a)},me(Ve,U,e)}()):Fe||(ae[U](Q,We),ae.setAttribute(R,1),ae.removeAttribute(R),nt&&(A=function(e){var t,n,r,o=this;if(o===e.target){t=o[R],o[R]=n=N(o);for(r in n){if(!(r in t))return O(0,o,r,t[r],n[r],X);if(n[r]!==t[r])return O(1,o,r,t[r],n[r],"MODIFICATION")}for(r in t)if(!(r in n))return O(2,o,r,t[r],n[r],$)}},O=function(e,t,n,r,o,l){var a={attrChange:e,currentTarget:t,attrName:n,prevValue:r,newValue:o};a[l]=e,i(a)},N=function(e){for(var t,n,r={},o=e.attributes,l=0,a=o.length;l$");if(t[q]="a",e.prototype=De(Se.prototype),e.prototype.constructor=e,window.customElements.define(n,e,t),!r.test(g.createElement("a",{is:n}).outerHTML)||!r.test((new e).outerHTML))throw t}(function ut(){return Reflect.construct(Se,[],ut)},{},"document-register-element-a")}catch(lt){w()}if(!e.noBuiltIn)try{if(Ke.call(g,"a","a").outerHTML.indexOf("is")<0)throw{}}catch(at){Ne=function(e){return{is:e.toLowerCase()}}}}); diff --git a/build/document-register-element.esm.js b/build/document-register-element.esm.js index a0b4594..906c283 100644 --- a/build/document-register-element.esm.js +++ b/build/document-register-element.esm.js @@ -641,6 +641,12 @@ export default function installCustomElements(window, polyfill) {'use strict'; attachShadow = HTMLElementPrototype.attachShadow, cloneNode = HTMLElementPrototype.cloneNode, + closest = HTMLElementPrototype.closest || function (name) { + var self = this; + while (self && self.nodeName !== name) + self = self.parentNode; + return self; + }, dispatchEvent = HTMLElementPrototype.dispatchEvent, getAttribute = HTMLElementPrototype.getAttribute, hasAttribute = HTMLElementPrototype.hasAttribute, @@ -1249,7 +1255,7 @@ export default function installCustomElements(window, polyfill) {'use strict'; i = getTypeIndex(node), counterAction ; - if (-1 < i) { + if ((-1 < i) && !closest.call(node, 'TEMPLATE')) { patchIfNotAlready(node, protos[i]); i = 0; if (action === ATTACHED && !node[ATTACHED]) { @@ -1273,8 +1279,6 @@ export default function installCustomElements(window, polyfill) {'use strict'; } } - - // V1 in da House! function CustomElementRegistry() {} diff --git a/build/document-register-element.js b/build/document-register-element.js index 4ff463f..b2a5161 100644 --- a/build/document-register-element.js +++ b/build/document-register-element.js @@ -1,2 +1,2 @@ /*! (C) Andrea Giammarchi - @WebReflection - ISC Style License */ -!function(e,t){"use strict";function n(){var e=A.splice(0,A.length);for(Ye=0;e.length;)e.shift().call(null,e.shift())}function r(e,t){for(var n=0,r=e.length;n1)&&H(this)}}}),Ue(l,Z,{value:function(e){-1>0),_="addEventListener",k="attached",x="Callback",q="detached",B="extends",Z="attributeChanged"+x,j=k+x,G="connected"+x,z="disconnected"+x,K="created"+x,X=q+x,$="ADDITION",Q="REMOVAL",W="DOMAttrModified",Y="DOMContentLoaded",J="DOMSubtreeModified",ee="<",te="=",ne=/^[A-Z][._A-Z0-9]*-[-._A-Z0-9]*$/,re=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],oe=[],le=[],ae="",ie=y.documentElement,ue=oe.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},ce=C.prototype,se=ce.hasOwnProperty,me=ce.isPrototypeOf,fe=C.defineProperty,pe=[],de=C.getOwnPropertyDescriptor,he=C.getOwnPropertyNames,Te=C.getPrototypeOf,Le=C.setPrototypeOf,Me=!!C.__proto__,Ee=!1,ve="__dreCEv1",He=e.customElements,ge=!/^force/.test(t.type)&&!!(He&&He.define&&He.get&&He.whenDefined),be=C.create||C,ye=e.Map||function(){var e,t=[],n=[];return{get:function(e){return n[ue.call(t,e)]},set:function(r,o){e=ue.call(t,r),e<0?n[t.push(r)-1]=o:n[e]=o}}},Ce=e.Promise||function(e){function t(e){for(r=!0;n.length;)n.shift()(e)}var n=[],r=!1,o={"catch":function(){return o},then:function(e){return n.push(e),r&&setTimeout(t,1),o}};return e(t),o},we=!1,Ae=be(null),Oe=be(null),Ne=new ye,De=function(e){return e.toLowerCase()},Ie=C.create||function it(e){return e?(it.prototype=e,new it):this},Fe=Le||(Me?function(e,t){return e.__proto__=t,e}:he&&de?function(){function e(e,t){for(var n,r=he(t),o=0,l=r.length;o
",new Se(function(e,t){if(e[0]&&"childList"==e[0].type&&!e[0].removedNodes[0].childNodes.length){P=de(Pe,"innerHTML");var n=P&&P.set;n&&fe(Pe,"innerHTML",{set:function(e){for(;this.lastChild;)this.removeChild(this.lastChild);n.call(this,e)}})}t.disconnect(),P=null}).observe(P,{childList:!0,subtree:!0}),P.innerHTML=""),Je||(Le||Me?(S=function(e,t){me.call(t,e)||p(e,t)},V=p):(S=function(e,t){e[U]||(e[U]=C(!0),p(e,t))},V=S),Re?(nt=!1,function(){var e=de(Pe,_),t=e.value,n=function(e){var t=new CustomEvent(W,{bubbles:!0});t.attrName=e,t.prevValue=Ze.call(this,e),t.newValue=null,t[Q]=t.attrChange=2,Ge.call(this,e),Be.call(this,t)},r=function(e,t){var n=je.call(this,e),r=n&&Ze.call(this,e),o=new CustomEvent(W,{bubbles:!0});ze.call(this,e,t),o.attrName=e,o.prevValue=n?r:null,o.newValue=t,n?o.MODIFICATION=o.attrChange=1:o[$]=o.attrChange=0,Be.call(this,o)},o=function(e){var t,n=e.currentTarget,r=n[U],o=e.propertyName;r.hasOwnProperty(o)&&(r=r[o],t=new CustomEvent(W,{bubbles:!0}),t.attrName=r.name,t.prevValue=r.value||null,t.newValue=r.value=n[o]||null,null==t.prevValue?t[$]=t.attrChange=0:t.MODIFICATION=t.attrChange=1,Be.call(n,t))};e.value=function(e,l,a){e===W&&this[Z]&&this.setAttribute!==r&&(this[U]={className:{name:"class",value:this.className}},this.setAttribute=r,this.removeAttribute=n,t.call(this,"propertychange",o)),t.call(this,e,l,a)},fe(Pe,_,e)}()):Se||(ie[_](W,We),ie.setAttribute(U,1),ie.removeAttribute(U),nt&&(O=function(e){var t,n,r,o=this;if(o===e.target){t=o[U],o[U]=n=D(o);for(r in n){if(!(r in t))return N(0,o,r,t[r],n[r],$);if(n[r]!==t[r])return N(1,o,r,t[r],n[r],"MODIFICATION")}for(r in t)if(!(r in n))return N(2,o,r,t[r],n[r],Q)}},N=function(e,t,n,r,o,l){var a={attrChange:e,currentTarget:t,attrName:n,prevValue:r,newValue:o};a[l]=e,u(a)},D=function(e){for(var t,n,r={},o=e.attributes,l=0,a=o.length;l$");if(n[B]="a",t.prototype=Ie(Ve.prototype),t.prototype.constructor=t,e.customElements.define(r,t,n),!o.test(y.createElement("a",{is:r}).outerHTML)||!o.test((new t).outerHTML))throw n}(function ut(){return Reflect.construct(Ve,[],ut)},{},"document-register-element-a")}catch(lt){b()}if(!t.noBuiltIn)try{if(Ke.call(y,"a","a").outerHTML.indexOf("is")<0)throw{}}catch(at){De=function(e){return{is:e.toLowerCase()}}}}(window); +!function(e,t){"use strict";function n(){var e=A.splice(0,A.length);for(Je=0;e.length;)e.shift().call(null,e.shift())}function r(e,t){for(var n=0,r=e.length;n1)&&H(this)}}}),Ue(l,Z,{value:function(e){-1>0),_="addEventListener",k="attached",x="Callback",q="detached",B="extends",Z="attributeChanged"+x,j=k+x,G="connected"+x,z="disconnected"+x,K="created"+x,X=q+x,$="ADDITION",Q="REMOVAL",W="DOMAttrModified",Y="DOMContentLoaded",J="DOMSubtreeModified",ee="<",te="=",ne=/^[A-Z][._A-Z0-9]*-[-._A-Z0-9]*$/,re=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],oe=[],le=[],ae="",ie=y.documentElement,ue=oe.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},ce=C.prototype,se=ce.hasOwnProperty,me=ce.isPrototypeOf,fe=C.defineProperty,pe=[],de=C.getOwnPropertyDescriptor,he=C.getOwnPropertyNames,Te=C.getPrototypeOf,Le=C.setPrototypeOf,Me=!!C.__proto__,Ee=!1,ve="__dreCEv1",He=e.customElements,ge=!/^force/.test(t.type)&&!!(He&&He.define&&He.get&&He.whenDefined),be=C.create||C,ye=e.Map||function(){var e,t=[],n=[];return{get:function(e){return n[ue.call(t,e)]},set:function(r,o){e=ue.call(t,r),e<0?n[t.push(r)-1]=o:n[e]=o}}},Ce=e.Promise||function(e){function t(e){for(r=!0;n.length;)n.shift()(e)}var n=[],r=!1,o={"catch":function(){return o},then:function(e){return n.push(e),r&&setTimeout(t,1),o}};return e(t),o},we=!1,Ae=be(null),Oe=be(null),Ne=new ye,De=function(e){return e.toLowerCase()},Ie=C.create||function ut(e){return e?(ut.prototype=e,new ut):this},Fe=Le||(Me?function(e,t){return e.__proto__=t,e}:he&&de?function(){function e(e,t){for(var n,r=he(t),o=0,l=r.length;o
",new Se(function(e,t){if(e[0]&&"childList"==e[0].type&&!e[0].removedNodes[0].childNodes.length){P=de(Pe,"innerHTML");var n=P&&P.set;n&&fe(Pe,"innerHTML",{set:function(e){for(;this.lastChild;)this.removeChild(this.lastChild);n.call(this,e)}})}t.disconnect(),P=null}).observe(P,{childList:!0,subtree:!0}),P.innerHTML=""),et||(Le||Me?(S=function(e,t){me.call(t,e)||p(e,t)},V=p):(S=function(e,t){e[U]||(e[U]=C(!0),p(e,t))},V=S),Re?(rt=!1,function(){var e=de(Pe,_),t=e.value,n=function(e){var t=new CustomEvent(W,{bubbles:!0});t.attrName=e,t.prevValue=je.call(this,e),t.newValue=null,t[Q]=t.attrChange=2,ze.call(this,e),Ze.call(this,t)},r=function(e,t){var n=Ge.call(this,e),r=n&&je.call(this,e),o=new CustomEvent(W,{bubbles:!0});Ke.call(this,e,t),o.attrName=e,o.prevValue=n?r:null,o.newValue=t,n?o.MODIFICATION=o.attrChange=1:o[$]=o.attrChange=0,Ze.call(this,o)},o=function(e){var t,n=e.currentTarget,r=n[U],o=e.propertyName;r.hasOwnProperty(o)&&(r=r[o],t=new CustomEvent(W,{bubbles:!0}),t.attrName=r.name,t.prevValue=r.value||null,t.newValue=r.value=n[o]||null,null==t.prevValue?t[$]=t.attrChange=0:t.MODIFICATION=t.attrChange=1,Ze.call(n,t))};e.value=function(e,l,a){e===W&&this[Z]&&this.setAttribute!==r&&(this[U]={className:{name:"class",value:this.className}},this.setAttribute=r,this.removeAttribute=n,t.call(this,"propertychange",o)),t.call(this,e,l,a)},fe(Pe,_,e)}()):Se||(ie[_](W,Ye),ie.setAttribute(U,1),ie.removeAttribute(U),rt&&(O=function(e){var t,n,r,o=this;if(o===e.target){t=o[U],o[U]=n=D(o);for(r in n){if(!(r in t))return N(0,o,r,t[r],n[r],$);if(n[r]!==t[r])return N(1,o,r,t[r],n[r],"MODIFICATION")}for(r in t)if(!(r in n))return N(2,o,r,t[r],n[r],Q)}},N=function(e,t,n,r,o,l){var a={attrChange:e,currentTarget:t,attrName:n,prevValue:r,newValue:o};a[l]=e,u(a)},D=function(e){for(var t,n,r={},o=e.attributes,l=0,a=o.length;l$");if(n[B]="a",t.prototype=Ie(Ve.prototype),t.prototype.constructor=t,e.customElements.define(r,t,n),!o.test(y.createElement("a",{is:r}).outerHTML)||!o.test((new t).outerHTML))throw n}(function ct(){return Reflect.construct(Ve,[],ct)},{},"document-register-element-a")}catch(at){b()}if(!t.noBuiltIn)try{if(Xe.call(y,"a","a").outerHTML.indexOf("is")<0)throw{}}catch(it){De=function(e){return{is:e.toLowerCase()}}}}(window); diff --git a/build/document-register-element.max.amd.js b/build/document-register-element.max.amd.js index 5adb844..a4bdc14 100644 --- a/build/document-register-element.max.amd.js +++ b/build/document-register-element.max.amd.js @@ -638,6 +638,12 @@ define(function(polyfill){'use strict'; attachShadow = HTMLElementPrototype.attachShadow, cloneNode = HTMLElementPrototype.cloneNode, + closest = HTMLElementPrototype.closest || function (name) { + var self = this; + while (self && self.nodeName !== name) + self = self.parentNode; + return self; + }, dispatchEvent = HTMLElementPrototype.dispatchEvent, getAttribute = HTMLElementPrototype.getAttribute, hasAttribute = HTMLElementPrototype.hasAttribute, @@ -1246,7 +1252,7 @@ define(function(polyfill){'use strict'; i = getTypeIndex(node), counterAction ; - if (-1 < i) { + if ((-1 < i) && !closest.call(node, 'TEMPLATE')) { patchIfNotAlready(node, protos[i]); i = 0; if (action === ATTACHED && !node[ATTACHED]) { @@ -1270,8 +1276,6 @@ define(function(polyfill){'use strict'; } } - - // V1 in da House! function CustomElementRegistry() {} diff --git a/build/document-register-element.max.js b/build/document-register-element.max.js index 68660ee..c13c2be 100644 --- a/build/document-register-element.max.js +++ b/build/document-register-element.max.js @@ -638,6 +638,12 @@ PERFORMANCE OF THIS SOFTWARE. attachShadow = HTMLElementPrototype.attachShadow, cloneNode = HTMLElementPrototype.cloneNode, + closest = HTMLElementPrototype.closest || function (name) { + var self = this; + while (self && self.nodeName !== name) + self = self.parentNode; + return self; + }, dispatchEvent = HTMLElementPrototype.dispatchEvent, getAttribute = HTMLElementPrototype.getAttribute, hasAttribute = HTMLElementPrototype.hasAttribute, @@ -1246,7 +1252,7 @@ PERFORMANCE OF THIS SOFTWARE. i = getTypeIndex(node), counterAction ; - if (-1 < i) { + if ((-1 < i) && !closest.call(node, 'TEMPLATE')) { patchIfNotAlready(node, protos[i]); i = 0; if (action === ATTACHED && !node[ATTACHED]) { @@ -1270,8 +1276,6 @@ PERFORMANCE OF THIS SOFTWARE. } } - - // V1 in da House! function CustomElementRegistry() {} diff --git a/build/document-register-element.node.js b/build/document-register-element.node.js index 7347146..abbbb36 100644 --- a/build/document-register-element.node.js +++ b/build/document-register-element.node.js @@ -641,6 +641,12 @@ function installCustomElements(window, polyfill) {'use strict'; attachShadow = HTMLElementPrototype.attachShadow, cloneNode = HTMLElementPrototype.cloneNode, + closest = HTMLElementPrototype.closest || function (name) { + var self = this; + while (self && self.nodeName !== name) + self = self.parentNode; + return self; + }, dispatchEvent = HTMLElementPrototype.dispatchEvent, getAttribute = HTMLElementPrototype.getAttribute, hasAttribute = HTMLElementPrototype.hasAttribute, @@ -1249,7 +1255,7 @@ function installCustomElements(window, polyfill) {'use strict'; i = getTypeIndex(node), counterAction ; - if (-1 < i) { + if ((-1 < i) && !closest.call(node, 'TEMPLATE')) { patchIfNotAlready(node, protos[i]); i = 0; if (action === ATTACHED && !node[ATTACHED]) { @@ -1273,8 +1279,6 @@ function installCustomElements(window, polyfill) {'use strict'; } } - - // V1 in da House! function CustomElementRegistry() {} diff --git a/pony/index.js b/pony/index.js index bdb9328..41ef7f9 100644 --- a/pony/index.js +++ b/pony/index.js @@ -641,6 +641,12 @@ function installCustomElements(window, polyfill) {'use strict'; attachShadow = HTMLElementPrototype.attachShadow, cloneNode = HTMLElementPrototype.cloneNode, + closest = HTMLElementPrototype.closest || function (name) { + var self = this; + while (self && self.nodeName !== name) + self = self.parentNode; + return self; + }, dispatchEvent = HTMLElementPrototype.dispatchEvent, getAttribute = HTMLElementPrototype.getAttribute, hasAttribute = HTMLElementPrototype.hasAttribute, @@ -1249,7 +1255,7 @@ function installCustomElements(window, polyfill) {'use strict'; i = getTypeIndex(node), counterAction ; - if (-1 < i) { + if ((-1 < i) && !closest.call(node, 'TEMPLATE')) { patchIfNotAlready(node, protos[i]); i = 0; if (action === ATTACHED && !node[ATTACHED]) { @@ -1273,8 +1279,6 @@ function installCustomElements(window, polyfill) {'use strict'; } } - - // V1 in da House! function CustomElementRegistry() {} diff --git a/pony/index.mjs b/pony/index.mjs index edeb1b9..deab926 100644 --- a/pony/index.mjs +++ b/pony/index.mjs @@ -641,6 +641,12 @@ export default function installCustomElements(window, polyfill) {'use strict'; attachShadow = HTMLElementPrototype.attachShadow, cloneNode = HTMLElementPrototype.cloneNode, + closest = HTMLElementPrototype.closest || function (name) { + var self = this; + while (self && self.nodeName !== name) + self = self.parentNode; + return self; + }, dispatchEvent = HTMLElementPrototype.dispatchEvent, getAttribute = HTMLElementPrototype.getAttribute, hasAttribute = HTMLElementPrototype.hasAttribute, @@ -1249,7 +1255,7 @@ export default function installCustomElements(window, polyfill) {'use strict'; i = getTypeIndex(node), counterAction ; - if (-1 < i) { + if ((-1 < i) && !closest.call(node, 'TEMPLATE')) { patchIfNotAlready(node, protos[i]); i = 0; if (action === ATTACHED && !node[ATTACHED]) { @@ -1273,8 +1279,6 @@ export default function installCustomElements(window, polyfill) {'use strict'; } } - - // V1 in da House! function CustomElementRegistry() {} diff --git a/src/document-register-element.js b/src/document-register-element.js index 748bca8..003b69a 100644 --- a/src/document-register-element.js +++ b/src/document-register-element.js @@ -208,6 +208,12 @@ var attachShadow = HTMLElementPrototype.attachShadow, cloneNode = HTMLElementPrototype.cloneNode, + closest = HTMLElementPrototype.closest || function (name) { + var self = this; + while (self && self.nodeName !== name) + self = self.parentNode; + return self; + }, dispatchEvent = HTMLElementPrototype.dispatchEvent, getAttribute = HTMLElementPrototype.getAttribute, hasAttribute = HTMLElementPrototype.hasAttribute, @@ -816,7 +822,7 @@ function verifyAndSetupAndAction(node, action) { i = getTypeIndex(node), counterAction ; - if (-1 < i) { + if ((-1 < i) && !closest.call(node, 'TEMPLATE')) { patchIfNotAlready(node, protos[i]); i = 0; if (action === ATTACHED && !node[ATTACHED]) { @@ -840,8 +846,6 @@ function verifyAndSetupAndAction(node, action) { } } - - // V1 in da House! function CustomElementRegistry() {} diff --git a/test/template.html b/test/template.html new file mode 100644 index 0000000..e110d1c --- /dev/null +++ b/test/template.html @@ -0,0 +1,33 @@ + + + + + + + +

+ Counter should be 2: 0 +

+ + + + \ No newline at end of file