@qualweb/qw-element
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -119,6 +119,9 @@ "use strict"; | ||
const selector = this.getElementSelector(); | ||
const treeSelector = this.getTreeSelector(); | ||
const elements = this.element.querySelectorAll(selector + ' > *' + treeSelector); | ||
let elements; | ||
try { | ||
elements = this.element.querySelectorAll(selector + ' > *'); | ||
} | ||
catch (e) { } | ||
const qwList = new Array(); | ||
for (const element of elements) { | ||
for (const element of elements || []) { | ||
this.addCSSRulesPropertyToElement(element); | ||
@@ -129,10 +132,2 @@ qwList.push(new QWElement(element, this.elementsCSSRules)); | ||
} | ||
getTreeSelector() { | ||
const attribute = this.getElementAttribute('shadowTree'); | ||
let result = ':not([shadowTree])'; | ||
if (attribute !== null) { | ||
result = `[shadowTree='${attribute}']`; | ||
} | ||
return result; | ||
} | ||
getElementChildTextContent(childName) { | ||
@@ -139,0 +134,0 @@ for (const child of this.element.children || []) { |
{ | ||
"name": "@qualweb/qw-element", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"description": "Utilities module for qualweb", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -24,8 +24,8 @@ class QWElement { | ||
public getCSSRules(): any { | ||
return this.elementsCSSRules?.get(this.element); | ||
return this.elementsCSSRules ?.get(this.element); | ||
} | ||
public hasCSSProperty(property: string, pseudoStyle?: string, media?: string): boolean { | ||
if (this.elementsCSSRules?.has(this.element)) { | ||
const rules = this.elementsCSSRules?.get(this.element); | ||
if (this.elementsCSSRules ?.has(this.element)) { | ||
const rules = this.elementsCSSRules ?.get(this.element); | ||
@@ -47,4 +47,4 @@ if (pseudoStyle && media) { | ||
public getCSSProperty(property: string, pseudoStyle?: string, media?: string): any { | ||
if (this.elementsCSSRules?.has(this.element)) { | ||
const rules = this.elementsCSSRules?.get(this.element); | ||
if (this.elementsCSSRules ?.has(this.element)) { | ||
const rules = this.elementsCSSRules ?.get(this.element); | ||
@@ -66,4 +66,4 @@ if (pseudoStyle && media) { | ||
public getCSSMediaRules(): any { | ||
if (this.elementsCSSRules?.has(this.element)) { | ||
const rules = this.elementsCSSRules?.get(this.element); | ||
if (this.elementsCSSRules ?.has(this.element)) { | ||
const rules = this.elementsCSSRules ?.get(this.element); | ||
return rules['media']; | ||
@@ -76,4 +76,4 @@ } | ||
public getCSSPseudoSelectorRules(pseudoSelector: string): any { | ||
if (this.elementsCSSRules?.has(this.element)) { | ||
const rules = this.elementsCSSRules?.get(this.element); | ||
if (this.elementsCSSRules ?.has(this.element)) { | ||
const rules = this.elementsCSSRules ?.get(this.element); | ||
return rules[pseudoSelector]; | ||
@@ -114,3 +114,3 @@ } | ||
for (const child of this.element.childNodes || []) { | ||
if (child.nodeType === 3 && child.textContent?.trim() !== '') { | ||
if (child.nodeType === 3 && child.textContent ?.trim() !== '') { | ||
hasText = true; | ||
@@ -140,6 +140,9 @@ } | ||
const selector = this.getElementSelector(); | ||
const treeSelector = this.getTreeSelector(); | ||
const elements = this.element.querySelectorAll(selector + ' > *' + treeSelector); | ||
let elements; | ||
try { | ||
elements = this.element.querySelectorAll(selector + ' > *'); | ||
} | ||
catch (e) { } | ||
const qwList = new Array<QWElement>(); | ||
for (const element of elements) { | ||
for (const element of elements || []) { | ||
this.addCSSRulesPropertyToElement(element); | ||
@@ -151,10 +154,2 @@ qwList.push(new QWElement(element, this.elementsCSSRules)); | ||
public getTreeSelector(): string { | ||
const attribute = this.getElementAttribute('shadowTree'); | ||
let result = ':not([shadowTree])'; | ||
if (attribute !== null) { | ||
result = `[shadowTree='${attribute}']` | ||
} | ||
return result; | ||
} | ||
@@ -161,0 +156,0 @@ public getElementChildTextContent(childName: string): string | undefined { |
Sorry, the diff of this file is not supported yet
34633
801