Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (let sheet of this.styleSheets) {
for (let rule of sheet.cssRules) {
let selectors = (rule.selectorText || '').split(/((?:[^,"']|"[^"]*"|'[^']*')+)/);
for (let selectorText of selectors) {
if (selectorText !== '' && selectorText !== ',' && element.matchesSelector(selectorText)) {
for (let prop of Array.from(rule.style)) {
css.setProperty(prop, rule.style.getPropertyValue(prop), rule.style.getPropertyPriority(prop));
}
break;
}
}
}
}
let style = new CSSStyleDeclaration;
style.cssText = element.attributes.style || '';
for (let prop of Array.from(style)) {
css.setProperty(prop, style.getPropertyValue(prop), style.getPropertyPriority(prop));
}
return css;
}
}
html.HTMLElement.prototype.__defineGetter__('style', function() {
if (!this._cssStyleDeclaration) {
this._cssStyleDeclaration = new cssom.CSSStyleDeclaration;
//console.log('creating style atribute on ' + this.nodeName)
this.addEventListener('DOMAttrModified', function(e) {
//console.log('style modified')
if ('style' === e.attrName) {
evaluateStyleAttribute.call(this, e.newValue);
}
});
evaluateStyleAttribute.call(this, this.getAttribute('style'));
}
return this._cssStyleDeclaration;
});
html.HTMLElement.prototype.__defineSetter__('style', function(val) {
html.HTMLElement.prototype.__defineGetter__('style', function() {
if (!this._cssStyleDeclaration) {
this._cssStyleDeclaration = new cssom.CSSStyleDeclaration;
//console.log('creating style atribute on ' + this.nodeName)
this.addEventListener('DOMAttrModified', function(e) {
//console.log('style modified')
if ('style' === e.attrName) {
evaluateStyleAttribute.call(this, e.newValue);
}
});
evaluateStyleAttribute.call(this, this.getAttribute('style'));
}
return this._cssStyleDeclaration;
});
html.HTMLElement.prototype.__defineSetter__('style', function(val) {
getComputedStyle(element) {
let css = new CSSStyleDeclaration;
for (let sheet of this.styleSheets) {
for (let rule of sheet.cssRules) {
let selectors = (rule.selectorText || '').split(/((?:[^,"']|"[^"]*"|'[^']*')+)/);
for (let selectorText of selectors) {
if (selectorText !== '' && selectorText !== ',' && element.matchesSelector(selectorText)) {
for (let prop of Array.from(rule.style)) {
css.setProperty(prop, rule.style.getPropertyValue(prop), rule.style.getPropertyPriority(prop));
}
break;
}
}
}
}
let style = new CSSStyleDeclaration;
_getComputedStyle() {
let css = new CSSStyleDeclaration;
css.cssText = this.attributes.style || '';
return css;
}
html.HTMLElement.prototype.__defineGetter__('style', function() {
var style = this._cssStyleDeclaration;
if (!style) {
style = this._cssStyleDeclaration = new cssom.CSSStyleDeclaration();
if (!this.getAttributeNode('style')) {
this.setAttribute('style', '');
}
}
return style;
});