How to use cssstyle - 10 common examples

To help you get started, we’ve selected a few cssstyle 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 dxnn / daimio / node_modules / d3 / node_modules / jsdom / lib / jsdom / level2 / style.js View on Github external
html.HTMLElement.prototype.__defineGetter__('style', function() {
  if (typeof this._style === 'string') {
    // currently, cssom's parse doesn't really work if you pass in
    // {state: 'name'}, so instead we just build a dummy sheet.
    var styleSheet = cssom.parse('dummy{' + this._style + '}');
    this._style = new cssstyle.CSSStyleDeclaration();
    if (styleSheet.cssRules.length > 0 && styleSheet.cssRules[0].style) {
      var newStyle = styleSheet.cssRules[0].style;
      for (var i = 0; i < newStyle.length; ++i) {
        var prop = newStyle[i];
        this._style.setProperty(
            prop,
            newStyle.getPropertyValue(prop),
            newStyle.getPropertyPriority(prop));
      }
    }
  }
  if (!this._style) {
    this._style = new cssstyle.CSSStyleDeclaration();

  }
  if (!this.getAttributeNode('style')) {
github bitovi-components / bit-c3 / c3-chart / node_modules / d3 / node_modules / jsdom / lib / jsdom / level2 / style.js View on Github external
defineGetter(html.HTMLElement.prototype, 'style', function() {
  if (typeof this._style === 'string') {
    // currently, cssom's parse doesn't really work if you pass in
    // {state: 'name'}, so instead we just build a dummy sheet.
    var styleSheet = cssom.parse('dummy{' + this._style + '}');
    this._style = new cssstyle.CSSStyleDeclaration();
    if (styleSheet.cssRules.length > 0 && styleSheet.cssRules[0].style) {
      var newStyle = styleSheet.cssRules[0].style;
      for (var i = 0; i < newStyle.length; ++i) {
        var prop = newStyle[i];
        this._style.setProperty(
            prop,
            newStyle.getPropertyValue(prop),
            newStyle.getPropertyPriority(prop));
      }
    }
  }
  if (!this._style) {
    this._style = new cssstyle.CSSStyleDeclaration();

  }
  if (!this.getAttributeNode('style')) {
github facebook / jest / src / lib / jsdom-compat.js View on Github external
// cssstyle has matured enough that the hacks below are no longer
// necessary, so don't panic.
try {
  var cssPropertyParsers = require('cssstyle/lib/parsers');
} catch (err) {
  // This error probably just means cssstyle is not installed yet, because
  // we're still in the process of upgrading jsdom. Don't worry about it
  // until jsdom has been updated to the latest version (v0.8.x).
}

if (cssPropertyParsers) {
  // The shorthandParser function should never return a string, but it
  // does when given an empty string. Here we detect that case and make it
  // return an empty object instead, to work around bugs in later code
  // that assume the result of shorthandParser is always an object.
  var shorthandParser = cssPropertyParsers.shorthandParser;
  cssPropertyParsers.shorthandParser = function() {
    var result = shorthandParser.apply(this, arguments);
    return result === '' ? {} : result;
  };

  // Current versions of the cssstyle parseInteger function can't actually
  // handle string inputs.
  var badInt = cssPropertyParsers.parseInteger('5');
  if (badInt !== '5') {
    cssPropertyParsers.parseInteger = function parseInteger(val) {
      return String(parseInt(val, 10));
    };
  }

  // Current versions of the cssstyle parseNumber function can't actually
  // handle string inputs.
github facebook / jest / src / lib / jsdom-compat.js View on Github external
// necessary, so don't panic.
try {
  var cssPropertyParsers = require('cssstyle/lib/parsers');
} catch (err) {
  // This error probably just means cssstyle is not installed yet, because
  // we're still in the process of upgrading jsdom. Don't worry about it
  // until jsdom has been updated to the latest version (v0.8.x).
}

if (cssPropertyParsers) {
  // The shorthandParser function should never return a string, but it
  // does when given an empty string. Here we detect that case and make it
  // return an empty object instead, to work around bugs in later code
  // that assume the result of shorthandParser is always an object.
  var shorthandParser = cssPropertyParsers.shorthandParser;
  cssPropertyParsers.shorthandParser = function() {
    var result = shorthandParser.apply(this, arguments);
    return result === '' ? {} : result;
  };

  // Current versions of the cssstyle parseInteger function can't actually
  // handle string inputs.
  var badInt = cssPropertyParsers.parseInteger('5');
  if (badInt !== '5') {
    cssPropertyParsers.parseInteger = function parseInteger(val) {
      return String(parseInt(val, 10));
    };
  }

  // Current versions of the cssstyle parseNumber function can't actually
  // handle string inputs.
  var badNum = cssPropertyParsers.parseNumber('0.5');
github facebook / jest / src / lib / jsdom-compat.js View on Github external
}

if (cssPropertyParsers) {
  // The shorthandParser function should never return a string, but it
  // does when given an empty string. Here we detect that case and make it
  // return an empty object instead, to work around bugs in later code
  // that assume the result of shorthandParser is always an object.
  var shorthandParser = cssPropertyParsers.shorthandParser;
  cssPropertyParsers.shorthandParser = function() {
    var result = shorthandParser.apply(this, arguments);
    return result === '' ? {} : result;
  };

  // Current versions of the cssstyle parseInteger function can't actually
  // handle string inputs.
  var badInt = cssPropertyParsers.parseInteger('5');
  if (badInt !== '5') {
    cssPropertyParsers.parseInteger = function parseInteger(val) {
      return String(parseInt(val, 10));
    };
  }

  // Current versions of the cssstyle parseNumber function can't actually
  // handle string inputs.
  var badNum = cssPropertyParsers.parseNumber('0.5');
  if (badNum !== '0.5') {
    cssPropertyParsers.parseNumber = function parseNumber(val) {
      return String(parseFloat(val, 10));
    };
  }
}
github facebook / jest / src / lib / jsdom-compat.js View on Github external
var result = shorthandParser.apply(this, arguments);
    return result === '' ? {} : result;
  };

  // Current versions of the cssstyle parseInteger function can't actually
  // handle string inputs.
  var badInt = cssPropertyParsers.parseInteger('5');
  if (badInt !== '5') {
    cssPropertyParsers.parseInteger = function parseInteger(val) {
      return String(parseInt(val, 10));
    };
  }

  // Current versions of the cssstyle parseNumber function can't actually
  // handle string inputs.
  var badNum = cssPropertyParsers.parseNumber('0.5');
  if (badNum !== '0.5') {
    cssPropertyParsers.parseNumber = function parseNumber(val) {
      return String(parseFloat(val, 10));
    };
  }
}

// We can't require jsdom/lib/jsdom/browser/utils directly, because it
// requires jsdom, which requires utils circularly, so the utils module
// won't be fully populated when its (non-existent) NOT_IMPLEMENTED
// property is imported elsewhere. Instead, the only thing that seems to
// work is to override the utils module in require.cache, so that we never
// have to evaluate the original module.
try {
  var utilsId = require.resolve('jsdom/lib/jsdom/browser/utils');
} catch (err) {
github YoavGivati / salmon / node / node_modules / jquery-latest / node_modules / jsdom / lib / jsdom / browser / index.js View on Github external
getComputedStyle: function(node) {
      var s = node.style,
          cs = new CSSStyleDeclaration(),
          forEach = Array.prototype.forEach;

      function setPropertiesFromRule(rule) {
        var selectors = rule.selectorText.split(/\s*,\s*/);
        var matched = false;
        selectors.forEach(function (selectorText) {
          if (!matched && matchesDontThrow(node, selectorText)) {
            matched = true;
            forEach.call(rule.style, function (property) {
              cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
            });
          }
        });
      }

      forEach.call(node.ownerDocument.styleSheets, function (sheet) {
github Nols1000 / hltv-scorebot / node_modules / jsdom / lib / jsdom / browser / Window.js View on Github external
getComputedStyle: function (node) {
    var s = node.style,
        cs = new CSSStyleDeclaration(),
        forEach = Array.prototype.forEach;

    function setPropertiesFromRule(rule) {
      if (!rule.selectorText) {
        return;
      }

      var selectors = rule.selectorText.split(cssSelectorSplitRE);
      var matched = false;
      selectors.forEach(function (selectorText) {
        if (selectorText !== "" && selectorText !== "," && !matched && matchesDontThrow(node, selectorText)) {
          matched = true;
          forEach.call(rule.style, function (property) {
            cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
          });
        }
github bitovi-components / bit-c3 / c3-chart / node_modules / d3 / node_modules / jsdom / lib / jsdom / browser / index.js View on Github external
getComputedStyle: function(node) {
      var s = node.style,
          cs = new CSSStyleDeclaration(),
          forEach = Array.prototype.forEach;

      function setPropertiesFromRule(rule) {
        if (!rule.selectorText) {
          return;
        }

        var selectors = rule.selectorText.split(cssSelectorSplitRE);
        var matched = false;
        selectors.forEach(function (selectorText) {
          if (selectorText !== '' && selectorText !== ',' && !matched && matchesDontThrow(node, selectorText)) {
            matched = true;
            forEach.call(rule.style, function (property) {
              cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
            });
          }
github julianbrowne / graffeine / node_modules / d3 / node_modules / jsdom / lib / jsdom / browser / index.js View on Github external
getComputedStyle: function(node) {
      var s = node.style,
          cs = new CSSStyleDeclaration(),
          forEach = Array.prototype.forEach;

      function setPropertiesFromRule(rule) {
        if (!rule.selectorText) {
          return;
        }

        var selectors = rule.selectorText.split(/\s*,\s*/);
        var matched = false;
        selectors.forEach(function (selectorText) {
          if (!matched && matchesDontThrow(node, selectorText)) {
            matched = true;
            forEach.call(rule.style, function (property) {
              cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
            });
          }