How to use the cssstyle/lib/parsers.parseNumber function in cssstyle

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 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) {