@qualweb/qw-element
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -151,2 +151,3 @@ 'use strict'; | ||
selector += ' > ' + this.getSelfLocationInParent(this.element); | ||
this.selector = selector; | ||
return selector; | ||
@@ -153,0 +154,0 @@ } |
{ | ||
"name": "@qualweb/qw-element", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Utilities module for qualweb", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,3 +7,3 @@ 'use strict'; | ||
private readonly elementsCSSRules?: Map<Element, any>; | ||
private selector:string; | ||
private selector: string; | ||
@@ -17,4 +17,4 @@ constructor(element: Element, elementsCSSRules?: Map<Element, any>) { | ||
private addCSSRulesPropertyToElement(element: Element | null): void { | ||
if (element && this.elementsCSSRules?.has(element)) { | ||
element.setAttribute('_cssRules', JSON.stringify(this.elementsCSSRules?.get(element))); | ||
if (element && this.elementsCSSRules ?.has(element)) { | ||
element.setAttribute('_cssRules', JSON.stringify(this.elementsCSSRules ?.get(element))); | ||
} | ||
@@ -97,3 +97,3 @@ } | ||
const clonedElem = <Element>this.element.cloneNode(true); | ||
clonedElem.removeAttribute( "_cssRules"); | ||
clonedElem.removeAttribute("_cssRules"); | ||
if (fullElement) { | ||
@@ -158,26 +158,27 @@ return clonedElem.outerHTML; | ||
if(this.selector === ""){ | ||
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'; | ||
} | ||
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<string>(); | ||
let parent = this.element.parentElement; | ||
let selector = 'html > '; | ||
const parents = new Array<string>(); | ||
let parent = this.element.parentElement; | ||
while (parent && parent.tagName.toLowerCase() !== 'html') { | ||
parents.unshift(this.getSelfLocationInParent(parent)); | ||
parent = parent['parentElement']; | ||
while (parent && parent.tagName.toLowerCase() !== 'html') { | ||
parents.unshift(this.getSelfLocationInParent(parent)); | ||
parent = parent['parentElement']; | ||
} | ||
selector += parents.join(' > '); | ||
selector += ' > ' + this.getSelfLocationInParent(this.element); | ||
this.selector = selector; | ||
return selector; | ||
} | ||
selector += parents.join(' > '); | ||
selector += ' > ' + this.getSelfLocationInParent(this.element); | ||
return selector;} | ||
else{ | ||
else { | ||
return this.selector; | ||
@@ -299,4 +300,4 @@ } | ||
if(this.getElementTagName() === 'iframe'){ | ||
const element = <HTMLIFrameElement> this.element; | ||
if (this.getElementTagName() === 'iframe') { | ||
const element = <HTMLIFrameElement>this.element; | ||
const contentWindow = element.contentWindow; | ||
@@ -335,3 +336,3 @@ | ||
public focusElement(): void { | ||
const htmlElement = <HTMLElement> this.element; | ||
const htmlElement = <HTMLElement>this.element; | ||
htmlElement.focus(); | ||
@@ -344,3 +345,3 @@ } | ||
public getShadowElement(selector: string): QWElement|null { | ||
public getShadowElement(selector: string): QWElement | null { | ||
const shadowRoot = this.element.shadowRoot; | ||
@@ -347,0 +348,0 @@ let element: Element | null = null; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
29797
676