How to use the cssom.parse 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 iazrael / ispriter / src / ispriter2.js View on Github external
var readStyleSheet = function(fileName) {

    // TODO workspace 未完全测试
    fileName = path.join(spriteConfig.input.workspace, fileName);
    if(!fs.existsSync(fileName)){
        return null;
    }
    var content = fs.readFileSync(fileName);
    var styleSheet = CSSOM.parse(content.toString());
    return styleSheet;
};
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / jsdom / browser / Window.js View on Github external
const reportException = require("../living/helpers/runtime-script-errors");
const { matchesDontThrow } = require("../living/helpers/selectors");
const SessionHistory = require("../living/window/SessionHistory");
const { contextifyWindow } = require("./documentfeatures.js");

const GlobalEventHandlersImpl = require("../living/nodes/GlobalEventHandlers-impl").implementation;
const WindowEventHandlersImpl = require("../living/nodes/WindowEventHandlers-impl").implementation;

// NB: the require() must be after assigning `module.exports` because this require() is circular
// TODO: this above note might not even be true anymore... figure out the cycle and document it, or clean up.
module.exports = Window;
const dom = require("../living");

const cssSelectorSplitRE = /((?:[^,"']|"[^"]*"|'[^']*')+)/;

const defaultStyleSheet = cssom.parse(require("./default-stylesheet"));

dom.Window = Window;

// NOTE: per https://heycam.github.io/webidl/#Global, all properties on the Window object must be own-properties.
// That is why we assign everything inside of the constructor, instead of using a shared prototype.
// You can verify this in e.g. Firefox or Internet Explorer, which do a good job with Web IDL compliance.

function Window(options) {
  EventTarget.setup(this);

  const rawPerformance = new RawPerformance();
  const windowInitialized = rawPerformance.now();

  const window = this;

  mixin(window, WindowEventHandlersImpl.prototype);
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / helpers / stylesheets.js View on Github external
exports.createStylesheet = (sheetText, elementImpl, baseURL) => {
  let sheet;
  try {
    sheet = cssom.parse(sheetText);
  } catch (e) {
    if (elementImpl._ownerDocument._defaultView) {
      const error = new Error("Could not parse CSS stylesheet");
      error.detail = sheetText;
      error.type = "css parsing";

      elementImpl._ownerDocument._defaultView._virtualConsole.emit("jsdomError", error);
    }
    return;
  }

  scanForImportRules(elementImpl, sheet.cssRules, baseURL);

  addStylesheet(sheet, elementImpl);
};
github material-components / material-components-web / scripts / check-pkg-for-release.js View on Github external
function checkCSSDependencyAddedInMDCPackage() {
  const name = getPkgName();
  const nameMDC = `mdc-${name}`;
  if (CSS_WHITELIST.indexOf(name) === -1 && NOT_MCW_DEP.indexOf(name) === -1) {
    const src = fs.readFileSync(path.join(process.env.PWD, MASTER_CSS_PATH), 'utf8');
    const cssRules = cssom.parse(src).cssRules;
    const cssRule = path.join(pkg.name, nameMDC);

    assert.notEqual(typeof cssRules.find((value) => {
      return value.href === cssRule;
    }), 'undefined',
    'FAILURE: Component ' + pkg.name + ' is not being imported in MDC Web. ' +
    'Please add ' + name + ' to ' + MASTER_CSS_PATH + ' import rule before commit.');
  }
}
github julianbrowne / graffeine / node_modules / d3 / node_modules / jsdom / node_modules / cssstyle / lib / CSSStyleDeclaration.js View on Github external
set: function (value) {
            var i;
            this._values = {};
            Array.prototype.splice.call(this, 0, this._length);
            this._importants = {};
            var dummyRule = CSSOM.parse('#bogus{' + value + '}').cssRules[0].style;
            var rule_length = dummyRule.length;
            var name;
            for (i = 0; i < rule_length; ++i) {
                name = dummyRule[i];
                this.setProperty(dummyRule[i], dummyRule.getPropertyValue(name), dummyRule.getPropertyPriority(name));
            }
        },
        enumerable: true,
github iazrael / ispriter / src / ispriter.js View on Github external
function readStyleSheet(fileName) {

    fileName = path.join(spriteConfig.workspace, fileName);
    if (!fs.existsSync(fileName)) {
        return null;
    }
    var content = fs.readFileSync(fileName);
    var styleSheet = CSSOM.parse(content.toString());
    return styleSheet;
};
github jsdom / jsdom / lib / jsdom / living / helpers / style-rules.js View on Github external
if (rule.media) {
        if (indexOf.call(rule.media, "screen") !== -1) {
          forEach.call(rule.cssRules, innerRule => {
            if (matches(innerRule, element)) {
              handleRule(innerRule);
            }
          });
        }
      } else if (matches(rule, element)) {
        handleRule(rule);
      }
    });
  }

  if (!parsedDefaultStyleSheet) {
    parsedDefaultStyleSheet = cssom.parse(defaultStyleSheet);
  }

  handleSheet(parsedDefaultStyleSheet);
  forEach.call(element.ownerDocument.styleSheets, handleSheet);
};
github brianleroux / css-slap-chop / css-slap-chop.js View on Github external
function parseCSS(str, cb) {
            var rules  = cssom.parse(str).cssRules.map(function(r) {
                return r.selectorText
            })
            cb(null, rules)
        }