diff --git a/js/dist/vd.min.js b/js/dist/vd.min.js index 6826da28a31efa8631d095b94d2b4605408befba..185d39718c1036f48e8ace6a781b4e5548bfcc20 100644 --- a/js/dist/vd.min.js +++ b/js/dist/vd.min.js @@ -1 +1 @@ -!function(e){e.behaviors.visualDebugger={body:document.body,utilities:e.vdUtilities,constants:{baseZIndex:0},classNames:{classNameVisualDebugger:"visual-debugger",classNameInitialized:"visual-debugger--initialized",classNameBaseLayer:"visual-debugger--base",classNameInstanceLayer:"instance-element",classNameInstanceLayerUnchecked:"instance-element--unchecked",classNameInstanceLayerChecked:"instance-element--checked",classNameInstanceLayerHover:"instance-element--hover",classNameObjectType:"object-type",classNameObjectTypeHover:"object-type--hover",classNameIconActivated:"icon-checkbox-checked",classNameIconDectivated:"icon-checkbox-unchecked",classNameCheckboxToggle:"checkbox-toggle",classNameSpanToggle:"span-toggle",classNameActivated:"item-activated",classNameDeactivated:"item-deactivated",classNameObjectTypeTyped:e=>`object-type--${e}`},layerAttributes:{layerIdAttributeName:"data-vd-id"},themeDebugNodes:null,triggerResizeObserver(e){const{body:t}=this,{layerIdAttributeName:s}=this.layerAttributes,{layerTargetIdAttributeName:a}=this.utilities.layerAttributes,n=new ResizeObserver((e=>{e.forEach((e=>{const n=e.target,i=n.getAttribute(s),c=t.querySelector(`[${a}="${i}"]`);this.setInstanceLayerSizeAndPosition(c,n)}))}));e.forEach((e=>{const{instanceRefElement:t}=e;n.observe(t)}))},triggerMutationObserver:function(e){new MutationObserver((()=>{e.forEach((e=>{this.setInstanceLayerSizeAndPosition(e.instanceLayer,e.instanceRefElement)}))})).observe(this.body,{attributes:!0,attributeFilter:["style"]})},regExs:{regexGetTemplateDebug:()=>new RegExp("^(THEME DEBUG|START RENDERER)$"),regexGetTemplateHook:()=>new RegExp("THEME HOOK: '([^']*)'"),regexGetTemplateSuggestions:()=>new RegExp("FILE NAME SUGGESTIONS:s*\ns*([^']*)s*\n*s*"),regexGetTemplateFilePath:()=>new RegExp("BEGIN( CUSTOM TEMPLATE)? OUTPUT from '([^']*)'"),regexGetTemplateEndOutput:()=>new RegExp("END OUTPUT from '([^']*)'"),regexGetCacheHit:()=>new RegExp("CACHE-HIT: (Yes|No)"),regexGetCacheTags:()=>new RegExp("^\\s?CACHE TAGS:s*\ns*([^']*)s*\n*s*"),regexGetCacheContexts:()=>new RegExp("^\\s?CACHE CONTEXTS:s*\ns*([^']*)s*\n*s*"),regexGetCacheKeys:()=>new RegExp("^\\s?CACHE KEYS:s*\ns*([^']*)s*\n*s*"),regexGetCacheMaxAge:()=>new RegExp("^\\s?CACHE MAX-AGE: (-?[0-9]*)"),regexGetPreBubblingCacheTags:()=>new RegExp("PRE-BUBBLING CACHE TAGS:s*\ns*([^']*)s*\n*s*"),regexGetPreBubblingCacheContexts:()=>new RegExp("PRE-BUBBLING CACHE CONTEXTS:s*\ns*([^']*)s*\n*s*"),regexGetPreBubblingCacheKeys:()=>new RegExp("PRE-BUBBLING CACHE KEYS:s*\ns*([^']*)s*\n*s*"),regexGetPreBubblingCacheMaxAge:()=>new RegExp("PRE-BUBBLING CACHE MAX-AGE: (-?[0-9]*)"),regexGetRenderingTime:()=>new RegExp("RENDERING TIME: (-?[0-9]*.?[0-9]*)")},controllerElement:null,getUniquePropertyHooks:e=>e.map((e=>e.instanceActiveElement.propertyHook)).filter(((e,t,s)=>s.indexOf(e)===t)).sort(),getCalculatedDomDepth(e){let t=0;for(;e.parentNode;)t++,e=e.parentNode;return t},generateBaseLayer(){const e=document.createElement("div"),{classNameVisualDebugger:t,classNameBaseLayer:s}=this.classNames;return e.classList.add(t),e.classList.add(s),e},getCheckedNodes(){return this.themeDebugNodes.filter((e=>e.instanceLayer.classList.contains(this.classNames.classNameInstanceLayerChecked)))},generateInstanceLayer(e,t,s){const a=document.createElement("div"),n=this.controllerElement,{classNameInstanceLayer:i,classNameInstanceLayerChecked:c,classNameInstanceLayerUnchecked:r,classNameObjectType:o,classNameObjectTypeTyped:l,classNameIconActivated:g,classNameIconDectivated:d,classNameCheckboxToggle:h,classNameSpanToggle:u,classNameActivated:m,classNameDeactivated:b}=this.classNames,{layerTargetIdAttributeName:E,instanceLayerActivatedAttributeName:y,layerAttributeIsVisible:x}=this.utilities.layerAttributes;a.classList.add(i,o,l(e.getObjectType()),r),a.setAttribute(E,s),a.setAttribute(x,!0),a.setAttribute(y,!1),a.style.zIndex=this.getCalculatedDomDepth(t),this.setInstanceLayerSizeAndPosition(a,t);const C=e,N=document.createElement("input");N.setAttribute("type","checkbox"),N.classList.add(h);const p=document.createElement("span");p.classList.add(u,m,g);const v=document.createElement("span");return v.classList.add(u,b,d),a.append(N,p,v),a.addEventListener("mouseenter",(()=>{N.focus({preventScroll:!0}),n.setActiveThemeElement(C)})),a.addEventListener("mouseleave",(()=>{N.blur(),n.resetActiveThemeElement(C)})),a.addEventListener("click",(()=>{this.getCheckedNodes().forEach((e=>{e.instanceLayer!==a&&e.instanceLayer.click()})),N.click()})),N.addEventListener("change",(()=>{a.setAttribute(y,N.checked),a.classList.toggle(c),a.classList.toggle(r),!0===N.checked?(N.focus(),n.setDefaultThemeElement(e)):(N.blur(),n.resetDefaultThemeElement(e))})),a},setInstanceLayerSizeAndPosition(e,t){const s=t.getBoundingClientRect(),a=Math.round(s.top+window.scrollY),n=Math.round(s.left+window.scrollX);let{width:i,height:c}=s;c=Math.floor(c),i=Math.floor(i),e.style.width=`${i}px`,e.style.height=`${c}px`,e.style.top=`${a}px`,e.style.left=`${n}px`},setthemeDebugNode(e,t,s){const{layerAttributeIsVisible:a,instanceLayerActivatedAttributeName:n}=this.utilities.layerAttributes,{classNameInstanceLayerHover:i,classNameObjectTypeHover:c}=this.classNames;return{instanceActiveElement:e,instanceLayer:t,instanceRefElement:s,showInstanceLayer(){this.instanceLayer.setAttribute(a,!0)},hideInstanceLayer(){this.instanceLayer.setAttribute(a,!1),"true"===this.instanceLayer.getAttribute(n)&&this.instanceLayer.click()},triggerMouseEnter(){this.instanceLayer.dispatchEvent(new MouseEvent("mouseenter")),this.instanceLayer.classList.add(i,c)},triggerMouseLeave(){this.instanceLayer.dispatchEvent(new MouseEvent("mouseleave")),this.instanceLayer.classList.remove(i,c)}}},attach:function(e,t){const{body:s}=this,{classNameInitialized:a}=this.classNames;s.classList.contains(a)||(s.classList.add(a),this.main(e,t,s))},main:function(t,s,a){const{regexGetTemplateDebug:n,regexGetTemplateHook:i,regexGetTemplateSuggestions:c,regexGetTemplateFilePath:r,regexGetCacheHit:o,regexGetCacheMaxAge:l,regexGetPreBubblingCacheTags:g,regexGetPreBubblingCacheContexts:d,regexGetPreBubblingCacheKeys:h,regexGetPreBubblingCacheMaxAge:u,regexGetRenderingTime:m,regexGetCacheTags:b,regexGetCacheContexts:E,regexGetCacheKeys:y}=this.regExs,{layerIdAttributeName:x}=this.layerAttributes,C=e.controllerElement;this.controllerElement=C;const N=this.generateBaseLayer();a.appendChild(N);let p=[],v=e.themeElement;v.init();document.querySelectorAll("*").forEach((e=>{const t=e.childNodes;Array.from(t).forEach((e=>{if(e.nodeType!==Node.COMMENT_NODE)return;if(n().test(e.textContent))return void v.setActivated();const t=e.textContent.match(o());if(t)return void v.setCacheHit(t[1]);const s=e.textContent.match(l());if(s)return void v.setCacheMaxAge(s[1]);const a=e.textContent.match(b());if(a)return void v.setCacheTags(a[1]);const C=e.textContent.match(E());if(C)return void v.setCacheContexts(C[1]);const A=e.textContent.match(y());if(A)return void v.setCacheKeys(A[1]);const L=e.textContent.match(g());if(L)return void v.setPreBubblingCacheTags(L[1]);const T=e.textContent.match(d());if(T)return void v.setPreBubblingCacheContexts(T[1]);const f=e.textContent.match(h());if(f)return void v.setPreBubblingCacheKeys(f[1]);const I=e.textContent.match(u());if(I)return void v.setPreBubblingCacheMaxAge(I[1]);const G=e.textContent.match(m());if(G)return void v.setRenderingTime(G[1]);const R=e.textContent.match(i());if(R)return v.setPropertyHook(R[1]),void v.setObjectType(R[1]);const B=e.textContent.match(c());if(B)return void v.setSuggestions(B[1]);const P=e.textContent.match(r());if(P){v.setFilePath(P[1]);const t=e.nextElementSibling;if(t&&t.nodeType===Node.ELEMENT_NODE&&null===v.dataNode){v.setDataNode(t);const e=Object.assign({},v),s=this.utilities.generateUniqueIdentifier(),a=this.generateInstanceLayer(e,t,s);t.setAttribute(x,s),N.appendChild(a),p.push(this.setthemeDebugNode(e,a,t))}v.reset()}}))})),this.themeDebugNodes=p,this.triggerMutationObserver(p),this.triggerResizeObserver(p),C.init(N,p),a.appendChild(C.generateControllerLayer()),C.executePostActivation()},detach:function(e,t,s){}}}(Drupal); \ No newline at end of file +!function(e){e.behaviors.visualDebugger={body:document.body,utilities:e.vdUtilities,constants:{baseZIndex:0},classNames:{classNameVisualDebugger:"visual-debugger",classNameInitialized:"visual-debugger--initialized",classNameBaseLayer:"visual-debugger--base",classNameInstanceLayer:"instance-element",classNameInstanceLayerUnchecked:"instance-element--unchecked",classNameInstanceLayerChecked:"instance-element--checked",classNameInstanceLayerHover:"instance-element--hover",classNameObjectType:"object-type",classNameObjectTypeHover:"object-type--hover",classNameIconActivated:"icon-checkbox-checked",classNameIconDectivated:"icon-checkbox-unchecked",classNameCheckboxToggle:"checkbox-toggle",classNameSpanToggle:"span-toggle",classNameActivated:"item-activated",classNameDeactivated:"item-deactivated",classNameObjectTypeTyped:e=>`object-type--${e}`},layerAttributes:{layerIdAttributeName:"data-vd-id"},themeDebugNodes:null,triggerResizeObserver(e){const{body:t}=this,{layerIdAttributeName:s}=this.layerAttributes,{layerTargetIdAttributeName:a}=this.utilities.layerAttributes,n=new ResizeObserver((e=>{e.forEach((e=>{const n=e.target,i=n.getAttribute(s),c=t.querySelector(`[${a}="${i}"]`);this.setInstanceLayerSizeAndPosition(c,n)}))}));e.forEach((e=>{const{instanceRefElement:t}=e;n.observe(t)}))},triggerMutationObserver:function(e){new MutationObserver((()=>{e.forEach((e=>{this.setInstanceLayerSizeAndPosition(e.instanceLayer,e.instanceRefElement)}))})).observe(this.body,{attributes:!0,attributeFilter:["style"]})},regExs:{regexGetTemplateDebug:()=>new RegExp("^(THEME DEBUG|START RENDERER)$"),regexGetTemplateHook:()=>new RegExp("THEME HOOK: '([^']*)'"),regexGetTemplateSuggestions:()=>new RegExp("FILE NAME SUGGESTIONS:s*\ns*([^']*)s*\n*s*"),regexGetTemplateFilePath:()=>new RegExp("BEGIN( CUSTOM TEMPLATE)? OUTPUT from '([^']*)'"),regexGetTemplateEndOutput:()=>new RegExp("END OUTPUT from '([^']*)'"),regexGetCacheHit:()=>new RegExp("CACHE-HIT: (Yes|No)"),regexGetCacheTags:()=>new RegExp("^\\s?CACHE TAGS:s*\ns*([^']*)s*\n*s*"),regexGetCacheContexts:()=>new RegExp("^\\s?CACHE CONTEXTS:s*\ns*([^']*)s*\n*s*"),regexGetCacheKeys:()=>new RegExp("^\\s?CACHE KEYS:s*\ns*([^']*)s*\n*s*"),regexGetCacheMaxAge:()=>new RegExp("^\\s?CACHE MAX-AGE: (-?[0-9]*)"),regexGetPreBubblingCacheTags:()=>new RegExp("PRE-BUBBLING CACHE TAGS:s*\ns*([^']*)s*\n*s*"),regexGetPreBubblingCacheContexts:()=>new RegExp("PRE-BUBBLING CACHE CONTEXTS:s*\ns*([^']*)s*\n*s*"),regexGetPreBubblingCacheKeys:()=>new RegExp("PRE-BUBBLING CACHE KEYS:s*\ns*([^']*)s*\n*s*"),regexGetPreBubblingCacheMaxAge:()=>new RegExp("PRE-BUBBLING CACHE MAX-AGE: (-?[0-9]*)"),regexGetRenderingTime:()=>new RegExp("RENDERING TIME: (-?[0-9]*.?[0-9]*)")},controllerElement:null,getUniquePropertyHooks:e=>e.map((e=>e.instanceActiveElement.propertyHook)).filter(((e,t,s)=>s.indexOf(e)===t)).sort(),getCalculatedDomDepth(e){let t=0;for(;e.parentNode;)t++,e=e.parentNode;return t},generateBaseLayer(){const e=document.createElement("div"),{classNameVisualDebugger:t,classNameBaseLayer:s}=this.classNames;return e.classList.add(t),e.classList.add(s),e},getCheckedNodes(){return this.themeDebugNodes.filter((e=>e.instanceLayer.classList.contains(this.classNames.classNameInstanceLayerChecked)))},generateInstanceLayer(e,t,s){const a=document.createElement("div"),n=this.controllerElement,{classNameInstanceLayer:i,classNameInstanceLayerChecked:c,classNameInstanceLayerUnchecked:r,classNameObjectType:o,classNameObjectTypeTyped:l,classNameIconActivated:g,classNameIconDectivated:d,classNameCheckboxToggle:h,classNameSpanToggle:u,classNameActivated:m,classNameDeactivated:b}=this.classNames,{layerTargetIdAttributeName:E,instanceLayerActivatedAttributeName:x,layerAttributeIsVisible:C}=this.utilities.layerAttributes;a.classList.add(i,o,l(e.getObjectType()),r),a.setAttribute(E,s),a.setAttribute(C,!0),a.setAttribute(x,!1),a.style.zIndex=this.getCalculatedDomDepth(t),this.setInstanceLayerSizeAndPosition(a,t);const y=e,N=document.createElement("input");N.setAttribute("type","checkbox"),N.classList.add(h);const p=document.createElement("span");p.classList.add(u,m,g);const v=document.createElement("span");return v.classList.add(u,b,d),a.append(N,p,v),a.addEventListener("mouseenter",(()=>{N.focus({preventScroll:!0}),n.setActiveThemeElement(y)})),a.addEventListener("mouseleave",(()=>{N.blur(),n.resetActiveThemeElement(y)})),a.addEventListener("click",(()=>{this.getCheckedNodes().forEach((e=>{e.instanceLayer!==a&&e.instanceLayer.click()})),N.click()})),N.addEventListener("change",(()=>{a.setAttribute(x,N.checked),a.classList.toggle(c),a.classList.toggle(r),!0===N.checked?(N.focus(),n.setDefaultThemeElement(e)):(N.blur(),n.resetDefaultThemeElement(e))})),a},setInstanceLayerSizeAndPosition(e,t){const s=t.getBoundingClientRect(),a=Math.round(s.top+window.scrollY),n=Math.round(s.left+window.scrollX);let{width:i,height:c}=s;c=Math.floor(c),i=Math.floor(i),e.style.width=`${i}px`,e.style.height=`${c}px`,e.style.top=`${a}px`,e.style.left=`${n}px`},getComments(e){for(var t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT,{acceptNode:function(e){return NodeFilter.FILTER_ACCEPT}}),s=t.nextNode(),a=[];s;)a.push(s),s=t.nextNode();return a},setthemeDebugNode(e,t,s){const{layerAttributeIsVisible:a,instanceLayerActivatedAttributeName:n}=this.utilities.layerAttributes,{classNameInstanceLayerHover:i,classNameObjectTypeHover:c}=this.classNames;return{instanceActiveElement:e,instanceLayer:t,instanceRefElement:s,showInstanceLayer(){this.instanceLayer.setAttribute(a,!0)},hideInstanceLayer(){this.instanceLayer.setAttribute(a,!1),"true"===this.instanceLayer.getAttribute(n)&&this.instanceLayer.click()},triggerMouseEnter(){this.instanceLayer.dispatchEvent(new MouseEvent("mouseenter")),this.instanceLayer.classList.add(i,c)},triggerMouseLeave(){this.instanceLayer.dispatchEvent(new MouseEvent("mouseleave")),this.instanceLayer.classList.remove(i,c)}}},attach:function(e,t){const{body:s}=this,{classNameInitialized:a}=this.classNames;s.classList.contains(a)||(s.classList.add(a),this.main(e,t,s))},main:function(t,s,a){const{regexGetTemplateDebug:n,regexGetTemplateHook:i,regexGetTemplateSuggestions:c,regexGetTemplateFilePath:r,regexGetCacheHit:o,regexGetCacheMaxAge:l,regexGetPreBubblingCacheTags:g,regexGetPreBubblingCacheContexts:d,regexGetPreBubblingCacheKeys:h,regexGetPreBubblingCacheMaxAge:u,regexGetRenderingTime:m,regexGetCacheTags:b,regexGetCacheContexts:E,regexGetCacheKeys:x}=this.regExs,{layerIdAttributeName:C}=this.layerAttributes,y=e.controllerElement;this.controllerElement=y;const N=this.generateBaseLayer();a.appendChild(N);let p=[],v=e.themeElement;v.init(),this.getComments(document).forEach((e=>{if(n().test(e.textContent))return void v.setActivated();const t=e.textContent.match(o());if(t)return void v.setCacheHit(t[1]);const s=e.textContent.match(l());if(s)return void v.setCacheMaxAge(s[1]);const a=e.textContent.match(b());if(a)return void v.setCacheTags(a[1]);const y=e.textContent.match(E());if(y)return void v.setCacheContexts(y[1]);const A=e.textContent.match(x());if(A)return void v.setCacheKeys(A[1]);const T=e.textContent.match(g());if(T)return void v.setPreBubblingCacheTags(T[1]);const L=e.textContent.match(d());if(L)return void v.setPreBubblingCacheContexts(L[1]);const f=e.textContent.match(h());if(f)return void v.setPreBubblingCacheKeys(f[1]);const I=e.textContent.match(u());if(I)return void v.setPreBubblingCacheMaxAge(I[1]);const G=e.textContent.match(m());if(G)return void v.setRenderingTime(G[1]);const R=e.textContent.match(i());if(R)return v.setPropertyHook(R[1]),void v.setObjectType(R[1]);const B=e.textContent.match(c());if(B)return void v.setSuggestions(B[1]);const P=e.textContent.match(r());if(P){v.setFilePath(P[1]);const t=e.nextElementSibling;if(t&&t.nodeType===Node.ELEMENT_NODE&&null===v.dataNode){v.setDataNode(t);const e=Object.assign({},v),s=this.utilities.generateUniqueIdentifier(),a=this.generateInstanceLayer(e,t,s);t.setAttribute(C,s),N.appendChild(a),p.push(this.setthemeDebugNode(e,a,t))}v.reset()}})),this.themeDebugNodes=p,this.triggerMutationObserver(p),this.triggerResizeObserver(p),y.init(N,p),a.appendChild(y.generateControllerLayer()),y.executePostActivation()},detach:function(e,t,s){}}}(Drupal); \ No newline at end of file diff --git a/js/source/vd.js b/js/source/vd.js index 26c90c0c79a265f15d8124ef686afb4bd0b9caed..918bfd0bfa15aef513f5770fb730c2697f02a5da 100644 --- a/js/source/vd.js +++ b/js/source/vd.js @@ -376,6 +376,39 @@ instanceLayerTarget.style.left = `${left}px`; }, + /** + * This function retrieves all nodes of type comment from the root element + * being passed into the function. This code was provided by Keith Shaw on + * Stack Overflow: https://stackoverflow.com/a/60234525. + * + * @param {object} root + * The element being analized and iterated. + * @returns {array} + * An array of comment nodes. + */ + getComments(root) { + var treeWalker = document.createTreeWalker( + root, + NodeFilter.SHOW_COMMENT, + { + "acceptNode": function acceptNode (node) { + return NodeFilter.FILTER_ACCEPT; + } + } + ); + + // skip the first node which is the node specified in the `root` + var currentNode = treeWalker.nextNode(); + + var nodeList = []; + while (currentNode) { + nodeList.push(currentNode); + currentNode = treeWalker.nextNode(); + } + + return nodeList; + }, + /** * Sets the theme debug node object, which is central for this app. * @param {object} instanceActiveElement @@ -498,152 +531,140 @@ let activeElement = Drupal.themeElement; activeElement.init(); - // Get all nodes in the document and loop through... - const allNodes = document.querySelectorAll("*"); - allNodes.forEach((node) => { - - // Loop through all child nodes. - const childNodes = node.childNodes; - Array.from(childNodes).forEach((child) => { - - // Analyze comment nodes only. - if (child.nodeType !== Node.COMMENT_NODE) return; - - // If there is no active template, return. - // if (activeElement === null) return; + // Get all comemnt nodes and loop through... + var commentNodes = this.getComments(document); + commentNodes.forEach((child) => { + // A THEME instance is found and initiated. + if (regexGetTemplateDebug().test(child.textContent)) { + activeElement.setActivated(); + return; + } - // A THEME instance is found and initiated. - if (regexGetTemplateDebug().test(child.textContent)) { - activeElement.setActivated(); - return; - } + // Test for a cache hit. + const cacheHit = child.textContent.match(regexGetCacheHit()); + if (cacheHit) { + activeElement.setCacheHit(cacheHit[1]); + return; + } - // Test for a cache hit. - const cacheHit = child.textContent.match(regexGetCacheHit()); - if (cacheHit) { - activeElement.setCacheHit(cacheHit[1]); - return; - } + // Test for cache max-age. + const cacheMaxAge = child.textContent.match(regexGetCacheMaxAge()); + if (cacheMaxAge) { + activeElement.setCacheMaxAge(cacheMaxAge[1]); + return; + } - // Test for cache max-age. - const cacheMaxAge = child.textContent.match(regexGetCacheMaxAge()); - if (cacheMaxAge) { - activeElement.setCacheMaxAge(cacheMaxAge[1]); - return; - } + // Test for cache tags. + const cacheTags = child.textContent.match(regexGetCacheTags()); + if (cacheTags) { + activeElement.setCacheTags(cacheTags[1]); + return; + } - // Test for cache tags. - const cacheTags = child.textContent.match(regexGetCacheTags()); - if (cacheTags) { - activeElement.setCacheTags(cacheTags[1]); - return; - } + // Test for cache contexts. + const cacheContexts = child.textContent.match(regexGetCacheContexts()); + if (cacheContexts) { + activeElement.setCacheContexts(cacheContexts[1]); + return; + } - // Test for cache contexts. - const cacheContexts = child.textContent.match(regexGetCacheContexts()); - if (cacheContexts) { - activeElement.setCacheContexts(cacheContexts[1]); - return; - } + // Test for cache contexts. + const cacheKeys = child.textContent.match(regexGetCacheKeys()); + if (cacheKeys) { + activeElement.setCacheKeys(cacheKeys[1]); + return; + } - // Test for cache contexts. - const cacheKeys = child.textContent.match(regexGetCacheKeys()); - if (cacheKeys) { - activeElement.setCacheKeys(cacheKeys[1]); - return; - } + // Test for pre-bubbing cache tags. + const preBubblingCacheTags = child.textContent.match(regexGetPreBubblingCacheTags()); + if (preBubblingCacheTags) { + activeElement.setPreBubblingCacheTags(preBubblingCacheTags[1]); + return; + } - // Test for pre-bubbing cache tags. - const preBubblingCacheTags = child.textContent.match(regexGetPreBubblingCacheTags()); - if (preBubblingCacheTags) { - activeElement.setPreBubblingCacheTags(preBubblingCacheTags[1]); - return; - } + // Test for pre-bubbing cache contexts. + const preBubblingCacheContexts = child.textContent.match(regexGetPreBubblingCacheContexts()); + if (preBubblingCacheContexts) { + activeElement.setPreBubblingCacheContexts(preBubblingCacheContexts[1]); + return; + } - // Test for pre-bubbing cache contexts. - const preBubblingCacheContexts = child.textContent.match(regexGetPreBubblingCacheContexts()); - if (preBubblingCacheContexts) { - activeElement.setPreBubblingCacheContexts(preBubblingCacheContexts[1]); - return; - } + // Test for pre-bubbing cache keys. + const preBubblingCacheKeys = child.textContent.match(regexGetPreBubblingCacheKeys()); + if (preBubblingCacheKeys) { + activeElement.setPreBubblingCacheKeys(preBubblingCacheKeys[1]); + return; + } - // Test for pre-bubbing cache keys. - const preBubblingCacheKeys = child.textContent.match(regexGetPreBubblingCacheKeys()); - if (preBubblingCacheKeys) { - activeElement.setPreBubblingCacheKeys(preBubblingCacheKeys[1]); - return; - } + // Test for pre-bubbing cache max-age. + const cachePreBubblingMaxAge = child.textContent.match(regexGetPreBubblingCacheMaxAge()); + if (cachePreBubblingMaxAge) { + activeElement.setPreBubblingCacheMaxAge(cachePreBubblingMaxAge[1]); + return; + } - // Test for pre-bubbing cache max-age. - const cachePreBubblingMaxAge = child.textContent.match(regexGetPreBubblingCacheMaxAge()); - if (cachePreBubblingMaxAge) { - activeElement.setPreBubblingCacheMaxAge(cachePreBubblingMaxAge[1]); - return; - } + // Test for pre-bubbing cache max-age. + const renderingTime = child.textContent.match(regexGetRenderingTime()); + if (renderingTime) { + activeElement.setRenderingTime(renderingTime[1]); + return; + } - // Test for pre-bubbing cache max-age. - const renderingTime = child.textContent.match(regexGetRenderingTime()); - if (renderingTime) { - activeElement.setRenderingTime(renderingTime[1]); - return; - } + // Gets the template hook. + const templateHookMatch = child.textContent.match(regexGetTemplateHook()); + if (templateHookMatch) { + activeElement.setPropertyHook(templateHookMatch[1]); + activeElement.setObjectType(templateHookMatch[1]); + return; + } - // Gets the template hook. - const templateHookMatch = child.textContent.match(regexGetTemplateHook()); - if (templateHookMatch) { - activeElement.setPropertyHook(templateHookMatch[1]); - activeElement.setObjectType(templateHookMatch[1]); - return; - } + // Gets the template suggestions. + const templateSuggestions = child.textContent.match( + regexGetTemplateSuggestions() + ); - // Gets the template suggestions. - const templateSuggestions = child.textContent.match( - regexGetTemplateSuggestions() - ); + if (templateSuggestions) { + activeElement.setSuggestions(templateSuggestions[1]); + return; + } - if (templateSuggestions) { - activeElement.setSuggestions(templateSuggestions[1]); - return; + // Gets the template file path and fills dataNode. + const templateFilePathMatch = child.textContent.match( + regexGetTemplateFilePath() + ); + if (templateFilePathMatch) { + + // Set the file path. + activeElement.setFilePath(templateFilePathMatch[1]); + + // Get the next element sibling (dataNode). + const dataNode = child.nextElementSibling; + + // Confirm it is a DOM element. + if ( + ( + dataNode && + dataNode.nodeType === Node.ELEMENT_NODE + ) && activeElement.dataNode === null + ) { + activeElement.setDataNode(dataNode); + const instanceActiveElement = Object.assign({}, activeElement); + const instanceLayerId = this.utilities.generateUniqueIdentifier(); + const instanceLayer = this.generateInstanceLayer(instanceActiveElement, dataNode, instanceLayerId); + dataNode.setAttribute(layerIdAttributeName, instanceLayerId); + baseLayer.appendChild(instanceLayer); + themeDebugNodes.push( + this.setthemeDebugNode( + instanceActiveElement, + instanceLayer, + dataNode, + ) + ); } - // Gets the template file path and fills dataNode. - const templateFilePathMatch = child.textContent.match( - regexGetTemplateFilePath() - ); - if (templateFilePathMatch) { - - // Set the file path. - activeElement.setFilePath(templateFilePathMatch[1]); - - // Get the next element sibling (dataNode). - const dataNode = child.nextElementSibling; - - // Confirm it is a DOM element. - if ( - ( - dataNode && - dataNode.nodeType === Node.ELEMENT_NODE - ) && activeElement.dataNode === null - ) { - activeElement.setDataNode(dataNode); - const instanceActiveElement = Object.assign({}, activeElement); - const instanceLayerId = this.utilities.generateUniqueIdentifier(); - const instanceLayer = this.generateInstanceLayer(instanceActiveElement, dataNode, instanceLayerId); - dataNode.setAttribute(layerIdAttributeName, instanceLayerId); - baseLayer.appendChild(instanceLayer); - themeDebugNodes.push( - this.setthemeDebugNode( - instanceActiveElement, - instanceLayer, - dataNode, - ) - ); - } - - activeElement.reset(); - } - }); + activeElement.reset(); + } }); this.themeDebugNodes = themeDebugNodes;