How to use the cssom.CSSStyleDeclaration function in cssom

To help you get started, we’ve selected a few cssom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devongovett / svgkit / src / SVGDocument.js View on Github external
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;
  }
}
github gatapia / jish / js.net / resources / dom / jsdom / lib / jsdom / level2 / style.js View on Github external
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) {
github andrewpmckenzie / node-jasmine-dom / node_modules / jsdom / lib / jsdom / level2 / style.js View on Github external
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) {
github devongovett / svgkit / src / SVGDocument.js View on Github external
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;
github devongovett / svgkit / src / elements / SVGElement.js View on Github external
_getComputedStyle() {
    let css = new CSSStyleDeclaration;
    css.cssText = this.attributes.style || '';
    return css;
  }
github thallium205 / BitcoinVisualizer / client.old / node_modules / jquery / node_modules / jsdom / lib / jsdom / level2 / style.js View on Github external
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;
});