Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
};
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);
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);
};
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.');
}
}
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,
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;
};
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);
};
function parseCSS(str, cb) {
var rules = cssom.parse(str).cssRules.map(function(r) {
return r.selectorText
})
cb(null, rules)
}