mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 12:20:04 +02:00
update node modules
This commit is contained in:
79
node_modules/cssom/lib/parse.js
generated
vendored
79
node_modules/cssom/lib/parse.js
generated
vendored
@@ -15,6 +15,7 @@ CSSOM.parse = function parse(token) {
|
||||
"selector" or
|
||||
"atRule" or
|
||||
"atBlock" or
|
||||
"conditionBlock" or
|
||||
"before-name" or
|
||||
"name" or
|
||||
"before-value" or
|
||||
@@ -34,18 +35,23 @@ CSSOM.parse = function parse(token) {
|
||||
"importRule-begin": true,
|
||||
"importRule": true,
|
||||
"atBlock": true,
|
||||
"conditionBlock": true,
|
||||
'documentRule-begin': true
|
||||
};
|
||||
|
||||
var styleSheet = new CSSOM.CSSStyleSheet();
|
||||
|
||||
// @type CSSStyleSheet|CSSMediaRule|CSSFontFaceRule|CSSKeyframesRule|CSSDocumentRule
|
||||
// @type CSSStyleSheet|CSSMediaRule|CSSSupportsRule|CSSFontFaceRule|CSSKeyframesRule|CSSDocumentRule
|
||||
var currentScope = styleSheet;
|
||||
|
||||
// @type CSSMediaRule|CSSKeyframesRule|CSSDocumentRule
|
||||
// @type CSSMediaRule|CSSSupportsRule|CSSKeyframesRule|CSSDocumentRule
|
||||
var parentRule;
|
||||
|
||||
var name, priority="", styleRule, mediaRule, importRule, fontFaceRule, keyframesRule, documentRule, hostRule;
|
||||
var ancestorRules = [];
|
||||
var hasAncestors = false;
|
||||
var prevScope;
|
||||
|
||||
var name, priority="", styleRule, mediaRule, supportsRule, importRule, fontFaceRule, keyframesRule, documentRule, hostRule;
|
||||
|
||||
var atKeyframesRegExp = /@(-(?:\w+-)+)?keyframes/g;
|
||||
|
||||
@@ -151,6 +157,13 @@ CSSOM.parse = function parse(token) {
|
||||
i += "media".length;
|
||||
buffer = "";
|
||||
break;
|
||||
} else if (token.indexOf("@supports", i) === i) {
|
||||
state = "conditionBlock";
|
||||
supportsRule = new CSSOM.CSSSupportsRule();
|
||||
supportsRule.__starts = i;
|
||||
i += "supports".length;
|
||||
buffer = "";
|
||||
break;
|
||||
} else if (token.indexOf("@host", i) === i) {
|
||||
state = "hostRule-begin";
|
||||
i += "host".length;
|
||||
@@ -196,17 +209,38 @@ CSSOM.parse = function parse(token) {
|
||||
state = "before-name";
|
||||
} else if (state === "atBlock") {
|
||||
mediaRule.media.mediaText = buffer.trim();
|
||||
|
||||
if (parentRule) {
|
||||
ancestorRules.push(parentRule);
|
||||
}
|
||||
|
||||
currentScope = parentRule = mediaRule;
|
||||
mediaRule.parentStyleSheet = styleSheet;
|
||||
buffer = "";
|
||||
state = "before-selector";
|
||||
} else if (state === "conditionBlock") {
|
||||
supportsRule.conditionText = buffer.trim();
|
||||
|
||||
if (parentRule) {
|
||||
ancestorRules.push(parentRule);
|
||||
}
|
||||
|
||||
currentScope = parentRule = supportsRule;
|
||||
supportsRule.parentStyleSheet = styleSheet;
|
||||
buffer = "";
|
||||
state = "before-selector";
|
||||
} else if (state === "hostRule-begin") {
|
||||
if (parentRule) {
|
||||
ancestorRules.push(parentRule);
|
||||
}
|
||||
|
||||
currentScope = parentRule = hostRule;
|
||||
hostRule.parentStyleSheet = styleSheet;
|
||||
buffer = "";
|
||||
state = "before-selector";
|
||||
} else if (state === "fontFaceRule-begin") {
|
||||
if (parentRule) {
|
||||
ancestorRules.push(parentRule);
|
||||
fontFaceRule.parentRule = parentRule;
|
||||
}
|
||||
fontFaceRule.parentStyleSheet = styleSheet;
|
||||
@@ -216,6 +250,7 @@ CSSOM.parse = function parse(token) {
|
||||
} else if (state === "keyframesRule-begin") {
|
||||
keyframesRule.name = buffer.trim();
|
||||
if (parentRule) {
|
||||
ancestorRules.push(parentRule);
|
||||
keyframesRule.parentRule = parentRule;
|
||||
}
|
||||
keyframesRule.parentStyleSheet = styleSheet;
|
||||
@@ -232,6 +267,7 @@ CSSOM.parse = function parse(token) {
|
||||
// FIXME: what if this '{' is in the url text of the match function?
|
||||
documentRule.matcher.matcherText = buffer.trim();
|
||||
if (parentRule) {
|
||||
ancestorRules.push(parentRule);
|
||||
documentRule.parentRule = parentRule;
|
||||
}
|
||||
currentScope = parentRule = documentRule;
|
||||
@@ -345,15 +381,39 @@ CSSOM.parse = function parse(token) {
|
||||
case "keyframeRule-begin":
|
||||
case "before-selector":
|
||||
case "selector":
|
||||
// End of media/document rule.
|
||||
// End of media/supports/document rule.
|
||||
if (!parentRule) {
|
||||
parseError("Unexpected }");
|
||||
}
|
||||
currentScope.__ends = i + 1;
|
||||
// Nesting rules aren't supported yet
|
||||
styleSheet.cssRules.push(currentScope);
|
||||
currentScope = styleSheet;
|
||||
parentRule = null;
|
||||
|
||||
// Handle rules nested in @media or @supports
|
||||
hasAncestors = ancestorRules.length > 0;
|
||||
|
||||
while (ancestorRules.length > 0) {
|
||||
parentRule = ancestorRules.pop();
|
||||
|
||||
if (
|
||||
parentRule.constructor.name === "CSSMediaRule"
|
||||
|| parentRule.constructor.name === "CSSSupportsRule"
|
||||
) {
|
||||
prevScope = currentScope;
|
||||
currentScope = parentRule;
|
||||
currentScope.cssRules.push(prevScope);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ancestorRules.length === 0) {
|
||||
hasAncestors = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAncestors) {
|
||||
currentScope.__ends = i + 1;
|
||||
styleSheet.cssRules.push(currentScope);
|
||||
currentScope = styleSheet;
|
||||
parentRule = null;
|
||||
}
|
||||
|
||||
buffer = "";
|
||||
state = "before-selector";
|
||||
break;
|
||||
@@ -393,6 +453,7 @@ CSSOM.CSSStyleSheet = require("./CSSStyleSheet").CSSStyleSheet;
|
||||
CSSOM.CSSStyleRule = require("./CSSStyleRule").CSSStyleRule;
|
||||
CSSOM.CSSImportRule = require("./CSSImportRule").CSSImportRule;
|
||||
CSSOM.CSSMediaRule = require("./CSSMediaRule").CSSMediaRule;
|
||||
CSSOM.CSSSupportsRule = require("./CSSSupportsRule").CSSSupportsRule;
|
||||
CSSOM.CSSFontFaceRule = require("./CSSFontFaceRule").CSSFontFaceRule;
|
||||
CSSOM.CSSHostRule = require("./CSSHostRule").CSSHostRule;
|
||||
CSSOM.CSSStyleDeclaration = require('./CSSStyleDeclaration').CSSStyleDeclaration;
|
||||
|
Reference in New Issue
Block a user