@qualweb/qw-element
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -8,2 +8,3 @@ 'use strict'; | ||
this.elementsCSSRules = elementsCSSRules; | ||
this.selector = ""; | ||
} | ||
@@ -79,2 +80,3 @@ addCSSRulesPropertyToElement(element) { | ||
const clonedElem = this.element.cloneNode(true); | ||
clonedElem.removeAttribute("_cssRules"); | ||
if (fullElement) { | ||
@@ -132,21 +134,26 @@ return clonedElem.outerHTML; | ||
getElementSelector() { | ||
if (this.element.tagName.toLowerCase() === 'html') { | ||
return 'html'; | ||
if (this.selector === "") { | ||
if (this.element.tagName.toLowerCase() === 'html') { | ||
return 'html'; | ||
} | ||
else if (this.element.tagName.toLowerCase() === 'head') { | ||
return 'html > head'; | ||
} | ||
else if (this.element.tagName.toLowerCase() === 'body') { | ||
return 'html > body'; | ||
} | ||
let selector = 'html > '; | ||
const parents = new Array(); | ||
let parent = this.element.parentElement; | ||
while (parent && parent.tagName.toLowerCase() !== 'html') { | ||
parents.unshift(this.getSelfLocationInParent(parent)); | ||
parent = parent['parentElement']; | ||
} | ||
selector += parents.join(' > '); | ||
selector += ' > ' + this.getSelfLocationInParent(this.element); | ||
return selector; | ||
} | ||
else if (this.element.tagName.toLowerCase() === 'head') { | ||
return 'html > head'; | ||
else { | ||
return this.selector; | ||
} | ||
else if (this.element.tagName.toLowerCase() === 'body') { | ||
return 'html > body'; | ||
} | ||
let selector = 'html > '; | ||
const parents = new Array(); | ||
let parent = this.element.parentElement; | ||
while (parent && parent.tagName.toLowerCase() !== 'html') { | ||
parents.unshift(this.getSelfLocationInParent(parent)); | ||
parent = parent['parentElement']; | ||
} | ||
selector += parents.join(' > '); | ||
selector += ' > ' + this.getSelfLocationInParent(this.element); | ||
return selector; | ||
} | ||
@@ -153,0 +160,0 @@ getSelfLocationInParent(element) { |
{ | ||
"name": "@qualweb/qw-element", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Utilities module for qualweb", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,2 +7,3 @@ 'use strict'; | ||
private readonly elementsCSSRules?: Map<Element, any>; | ||
private selector:string; | ||
@@ -12,2 +13,3 @@ constructor(element: Element, elementsCSSRules?: Map<Element, any>) { | ||
this.elementsCSSRules = elementsCSSRules; | ||
this.selector = ""; | ||
} | ||
@@ -95,2 +97,3 @@ | ||
const clonedElem = <Element>this.element.cloneNode(true); | ||
clonedElem.removeAttribute( "_cssRules"); | ||
if (fullElement) { | ||
@@ -155,2 +158,4 @@ return clonedElem.outerHTML; | ||
if(this.selector === ""){ | ||
if (this.element.tagName.toLowerCase() === 'html') { | ||
@@ -176,3 +181,6 @@ return 'html'; | ||
return selector; | ||
return selector;} | ||
else{ | ||
return this.selector; | ||
} | ||
} | ||
@@ -179,0 +187,0 @@ |
Sorry, the diff of this file is not supported yet
29622
673