@qualweb/qw-element
Advanced tools
Comparing version 0.1.21 to 0.1.22
@@ -6,2 +6,4 @@ "use strict"; | ||
constructor(element, elementsCSSRules) { | ||
this.computedStyle = getComputedStyle(element, null); | ||
; | ||
this.element = element; | ||
@@ -150,3 +152,23 @@ this.elementsCSSRules = elementsCSSRules; | ||
if (fullElement) { | ||
let children = this.element.children; | ||
let attributeArray = []; | ||
for (let child of children) { | ||
let cssRulesValue = child.getAttribute('_cssRules'); | ||
let selectorValue = child.getAttribute('_selector'); | ||
attributeArray.push({ cssRulesValue, selectorValue }); | ||
child.removeAttribute('_cssRules'); | ||
child.removeAttribute('_selector'); | ||
} | ||
result = this.element.outerHTML; | ||
let i = 0; | ||
for (let child of children) { | ||
let atributes = attributeArray[i]; | ||
if (!!atributes.cssRulesValue) { | ||
child.setAttribute('_cssRules', atributes.cssRulesValue); | ||
} | ||
if (!!atributes.selectorValue) { | ||
child.setAttribute('_selector', atributes.selectorValue); | ||
} | ||
i++; | ||
} | ||
} | ||
@@ -263,4 +285,3 @@ else if (withText) { | ||
getElementStyleProperty(property, pseudoStyle) { | ||
const styles = getComputedStyle(this.element, pseudoStyle); | ||
return styles.getPropertyValue(property); | ||
return this.computedStyle.getPropertyValue(property); | ||
} | ||
@@ -267,0 +288,0 @@ getElementTagName() { |
{ | ||
"name": "@qualweb/qw-element", | ||
"version": "0.1.21", | ||
"version": "0.1.22", | ||
"description": "Utilities module for qualweb", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -6,4 +6,6 @@ class QWElement { | ||
private selector: string; | ||
private computedStyle:any; | ||
constructor(element: Element, elementsCSSRules?: Map<Element, any>) { | ||
this.computedStyle = getComputedStyle(element, null);; | ||
this.element = element; | ||
@@ -170,3 +172,23 @@ this.elementsCSSRules = elementsCSSRules; | ||
if (fullElement) { | ||
let children = this.element.children; | ||
let attributeArray: any=[]; | ||
for(let child of children){ | ||
let cssRulesValue= child.getAttribute('_cssRules'); | ||
let selectorValue = child.getAttribute('_selector'); | ||
attributeArray.push({cssRulesValue,selectorValue}) | ||
child.removeAttribute('_cssRules'); | ||
child.removeAttribute('_selector'); | ||
} | ||
result = this.element.outerHTML; | ||
let i = 0; | ||
for(let child of children){ | ||
let atributes= attributeArray[i]; | ||
if (!!atributes.cssRulesValue) { | ||
child.setAttribute('_cssRules', atributes.cssRulesValue); | ||
} | ||
if (!!atributes.selectorValue) { | ||
child.setAttribute('_selector', atributes.selectorValue); | ||
} | ||
i++; | ||
} | ||
} | ||
@@ -300,4 +322,3 @@ else if (withText) { | ||
public getElementStyleProperty(property: string, pseudoStyle: string | null): string { | ||
const styles = getComputedStyle(this.element, pseudoStyle); | ||
return styles.getPropertyValue(property); | ||
return this.computedStyle.getPropertyValue(property); | ||
} | ||
@@ -304,0 +325,0 @@ |
38068
883