@tbela99/css-parser 1.6.8 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/index-umd-web.js +221 -244
- package/dist/index.cjs +220 -243
- package/dist/index.d.ts +8 -1
- package/dist/package.json.js +2 -2
- package/dist/src/data/properties.json.js +1 -1
- package/dist/src/data/validation.json.js +8 -2
- package/dist/src/lib/ast/clone.js +1 -1
- package/dist/src/lib/ast/expand.js +1 -1
- package/dist/src/lib/ast/features/calc.js +1 -1
- package/dist/src/lib/ast/features/if.js +1 -1
- package/dist/src/lib/ast/features/index.js +1 -1
- package/dist/src/lib/ast/features/inlinecssvariables.js +1 -1
- package/dist/src/lib/ast/features/prefix.js +1 -1
- package/dist/src/lib/ast/features/shorthand.js +39 -22
- package/dist/src/lib/ast/features/transform.js +1 -1
- package/dist/src/lib/ast/features/type.js +1 -1
- package/dist/src/lib/ast/find.js +1 -1
- package/dist/src/lib/ast/math/expression.js +1 -1
- package/dist/src/lib/ast/math/math.js +1 -1
- package/dist/src/lib/ast/minify.js +31 -3
- package/dist/src/lib/ast/node.js +1 -1
- package/dist/src/lib/ast/transform/compute.js +1 -1
- package/dist/src/lib/ast/transform/matrix.js +1 -1
- package/dist/src/lib/ast/transform/minify.js +1 -1
- package/dist/src/lib/ast/transform/perspective.js +1 -1
- package/dist/src/lib/ast/transform/rotate.js +1 -1
- package/dist/src/lib/ast/transform/scale.js +1 -1
- package/dist/src/lib/ast/transform/skew.js +1 -1
- package/dist/src/lib/ast/transform/translate.js +1 -1
- package/dist/src/lib/ast/transform/utils.js +1 -1
- package/dist/src/lib/ast/types.js +1 -1
- package/dist/src/lib/ast/walk.js +1 -1
- package/dist/src/lib/fs/resolve.js +1 -1
- package/dist/src/lib/parser/declaration/list.js +11 -1
- package/dist/src/lib/parser/declaration/map.js +2 -2
- package/dist/src/lib/parser/declaration/set.js +1 -1
- package/dist/src/lib/parser/linesmap.js +1 -1
- package/dist/src/lib/parser/parse.js +9 -18
- package/dist/src/lib/parser/source.js +1 -1
- package/dist/src/lib/parser/tokenize.js +1 -1
- package/dist/src/lib/parser/utils/angle.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-container.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-generic.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-import.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-media.js +2 -2
- package/dist/src/lib/parser/utils/at-rule-support.js +2 -2
- package/dist/src/lib/parser/utils/at-rule-when-else.js +1 -1
- package/dist/src/lib/parser/utils/at-rule.js +1 -1
- package/dist/src/lib/parser/utils/base64.js +1 -1
- package/dist/src/lib/parser/utils/cache.js +1 -1
- package/dist/src/lib/parser/utils/config.js +1 -1
- package/dist/src/lib/parser/utils/declaration.js +1 -1
- package/dist/src/lib/parser/utils/eq.js +1 -1
- package/dist/src/lib/parser/utils/hash.js +1 -1
- package/dist/src/lib/parser/utils/selector.js +1 -1
- package/dist/src/lib/parser/utils/text.js +1 -1
- package/dist/src/lib/parser/utils/token.js +2 -1
- package/dist/src/lib/parser/utils/type.js +1 -1
- package/dist/src/lib/printer/render.js +2 -2
- package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
- package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
- package/dist/src/lib/syntax/color/a98rgb.js +1 -1
- package/dist/src/lib/syntax/color/alpha.js +1 -1
- package/dist/src/lib/syntax/color/cmyk.js +1 -1
- package/dist/src/lib/syntax/color/color-mix.js +1 -1
- package/dist/src/lib/syntax/color/color.js +1 -1
- package/dist/src/lib/syntax/color/hex.js +1 -1
- package/dist/src/lib/syntax/color/hsl.js +1 -1
- package/dist/src/lib/syntax/color/hwb.js +1 -1
- package/dist/src/lib/syntax/color/lab.js +1 -1
- package/dist/src/lib/syntax/color/lch.js +1 -1
- package/dist/src/lib/syntax/color/oklab.js +1 -1
- package/dist/src/lib/syntax/color/oklch.js +1 -1
- package/dist/src/lib/syntax/color/p3.js +1 -1
- package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
- package/dist/src/lib/syntax/color/rec2020.js +1 -1
- package/dist/src/lib/syntax/color/relative-color.js +1 -1
- package/dist/src/lib/syntax/color/rgb.js +1 -1
- package/dist/src/lib/syntax/color/srgb.js +1 -1
- package/dist/src/lib/syntax/color/utils/color-type.js +1 -1
- package/dist/src/lib/syntax/color/utils/colorspace.js +1 -1
- package/dist/src/lib/syntax/color/utils/components.js +1 -1
- package/dist/src/lib/syntax/color/utils/distance.js +1 -1
- package/dist/src/lib/syntax/color/utils/make-color.js +1 -1
- package/dist/src/lib/syntax/color/utils/matrix.js +1 -1
- package/dist/src/lib/syntax/color/xyz.js +1 -1
- package/dist/src/lib/syntax/color/xyzd50.js +1 -1
- package/dist/src/lib/syntax/constants.js +1 -1
- package/dist/src/lib/syntax/syntax.js +1 -1
- package/dist/src/lib/validation/config.js +20 -3
- package/dist/src/lib/validation/match.js +98 -196
- package/dist/src/lib/validation/parser/parse.js +8 -3
- package/dist/src/lib/validation/parser/typedef.js +1 -1
- package/dist/src/lib/validation/utils/list.js +1 -1
- package/dist/src/node.js +2 -1
- package/dist/src/types.js +1 -1
- package/dist/src/utils/sync.js +1 -1
- package/dist/src/web.js +2 -1
- package/package.json +7 -6
- package/CONTRIBUTING.md +0 -119
package/dist/index.d.ts
CHANGED
|
@@ -6687,6 +6687,13 @@ declare function setNodeProperty(node: AstNode$1, key: 'errors', value: ErrorDes
|
|
|
6687
6687
|
*/
|
|
6688
6688
|
declare function setNodeProperty(node: AstNode$1, key: 'tokens', value: Token$1[] | null): void;
|
|
6689
6689
|
|
|
6690
|
+
/**
|
|
6691
|
+
* parse mdn data syntax
|
|
6692
|
+
* @param syntax
|
|
6693
|
+
* @returns
|
|
6694
|
+
*/
|
|
6695
|
+
declare function parseSyntax(syntax: string): ValidationToken$1[];
|
|
6696
|
+
|
|
6690
6697
|
declare let version: string;
|
|
6691
6698
|
|
|
6692
6699
|
/**
|
|
@@ -7076,5 +7083,5 @@ declare function transform(options: ParseInputStreamOptions & TransformOptions):
|
|
|
7076
7083
|
*/
|
|
7077
7084
|
declare function transform(options: ParseInputFileOptions & TransformOptions): Promise<TransformResult>;
|
|
7078
7085
|
|
|
7079
|
-
export { ColorType$1 as ColorType, EnumAstNodeStatus$1 as EnumAstNodeStatus, EnumToken, FeatureWalkMode, ModuleCaseTransformEnum, ModuleScopeEnumOptions, ResponseType, SourceMap, ValidationLevel, WalkerEvent, WalkerOptionEnum, cloneNode, convertColor, dirname, expand, find, findAll, findByValue, findLast, getNodeProperty, isOkLabClose, load, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseSync, render, renderValue as renderToken, replaceNodeOrValue, resolve, setNodeProperty, transform, transformFile, transformSync, version, walk, walkValues };
|
|
7086
|
+
export { ColorType$1 as ColorType, EnumAstNodeStatus$1 as EnumAstNodeStatus, EnumToken, FeatureWalkMode, ModuleCaseTransformEnum, ModuleScopeEnumOptions, ResponseType, SourceMap, ValidationLevel, WalkerEvent, WalkerOptionEnum, cloneNode, convertColor, dirname, expand, find, findAll, findByValue, findLast, getNodeProperty, isOkLabClose, load, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseSync, parseSyntax, render, renderValue as renderToken, replaceNodeOrValue, resolve, setNodeProperty, transform, transformFile, transformSync, version, walk, walkValues };
|
|
7080
7087
|
export type { AddToken, AndToken, AngleToken, AstAtRule, AstComment, AstDeclaration, AstInvalidAtRule, AstInvalidDeclaration, AstInvalidRule, AstKeyframesAtRule, AstKeyframesRule, AstNode$1 as AstNode, AstNodeStatus, AstRule, AstRuleList, AstStyleSheet, AstValueMatcher, AtRuleToken, AtRuleVisitorHandler, AttrEndToken, AttrStartToken, AttrToken, Background, BackgroundAttachmentMapping, BackgroundPosition, BackgroundPositionClass, BackgroundPositionConstraints, BackgroundPositionMapping, BackgroundProperties, BackgroundRepeat, BackgroundRepeatMapping, BackgroundSize, BackgroundSizeMapping, BadCDOCommentToken, BadCommentToken, BadStringToken, BadUrlToken, BaseToken, BinaryExpressionNode, BinaryExpressionToken, BlockEndToken, BlockStartToken, Border, BorderColor, BorderColorClass, BorderProperties, BorderRadius, CDOCommentToken, ChildCombinatorToken, ClassSelectorToken, ColonToken, ColorToken, ColumnCombinatorToken, CommaToken, CommentToken, ComposesSelectorToken, ConstraintsMapping, ContainMatchToken, ContainerStyleRangeToken, CssTypeTokenType, CssVariableImportTokenType, CssVariableMapTokenType, CssVariableToken, DashMatchToken, DashedIdentToken, DeclarationVisitorHandler, DelimToken, DescendantCombinatorToken, DimensionToken, DivToken, DoubleColonToken, EOFToken, EndMatchToken, EqualMatchToken, ErrorDescription$1 as ErrorDescription, FlexToken, Font, FontFamily, FontProperties, FontWeight, FontWeightConstraints, FontWeightMapping, FractionToken, FrequencyToken, FunctionDefToken, FunctionImageToken, FunctionToken, FunctionURLToken, GenericVisitorAstNodeHandlerMap, GenericVisitorAstNodeSyncHandlerMap, GenericVisitorAsyncResult, GenericVisitorHandler, GenericVisitorResult, GenericVisitorSyncHandler, GenericVisitorSyncResult, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, IfConditionToken, IfElseConditionToken, ImportantToken, IncludeMatchToken, InfinityToken, InvalidAttrToken, InvalidClassSelectorToken, InvalidMediaQueryToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, LoadResult, Map$1 as Map, MatchExpressionToken, MatchedSelector, MediaFeatureOnlyToken, MediaFeatureToken, MediaQueryConditionToken, MediaQueryUnaryFeatureToken, MediaRangeQueryToken, MinifyFeature, MinifyFeatureOptions, MinifyOptions, ModuleAsyncOptions, ModuleSyncOptions, MulToken, NaNToken, NameSpaceAttributeToken, NegativeInfinityToken, NestingSelectorToken, NextSiblingCombinatorToken, NotToken, NumberToken, OptimizedSelector, OptimizedSelectorToken, OrToken, Outline, OutlineProperties, ParensEndToken, ParensStartToken, ParensToken, ParseInfo$1 as ParseInfo, ParseInputFileOptions, ParseInputOptions, ParseInputStreamOptions, ParseResult, ParseResultStats, ParseSourceOptions, ParseTokenOptions, ParsedVisitorHandlers, ParserOptions, ParserSourceMapOptions, ParserSyncOptions, PercentageToken, Prefix, PropertiesConfig, PropertiesConfigProperties, PropertyListOptions, PropertyMapType, PropertySetType, PropertyType, PseudoClassFunctionToken, PseudoClassToken, PseudoElementToken, PseudoPageToken, PurpleBackgroundAttachment, RawNodeToken, RawSelectorTokens, RenderOptions, RenderResult, ResolutionToken, ResolvedPath, RuleVisitorHandler, SemiColonToken, Separator, ShorthandDef, ShorthandMapType, ShorthandProperties, ShorthandPropertyType, ShorthandType, SinglePropertyType, SinglePropertyTypeMapping, SourceLocation, SourceMapObject, StartMatchToken, StringToken, SubToken, SubsequentCombinatorToken, SupportsQueryConditionToken, SupportsQueryUnaryConditionToken, TimeToken, TimelineFunctionToken, TimingFunctionToken, Token$1 as Token, TokenSearchResult, TokenizeResult, TransformOptions, TransformResult, TransformSyncOptions, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationMediaFeature, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, ValidationToken$1 as ValidationToken, Value, ValueVisitorHandler, ValueVisitorSyncHandler, VariableScopeInfo, VisitorNodeMap, VisitorSyncNodeMap, WalkAttributesResult, WalkResult, WalkerFilter, WalkerOption, WalkerOptions, WalkerValueFilter, WhenElseQueryConditionToken, WhenElseUnaryConditionToken, WhitespaceToken, WrappedValuesToken };
|
package/dist/package.json.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.7.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
var declarations = {
|
|
@@ -4712,7 +4712,13 @@ var atRules = {
|
|
|
4712
4712
|
syntax: " @bottom-right-corner { <declaration-list> }"
|
|
4713
4713
|
},
|
|
4714
4714
|
"@function": {
|
|
4715
|
-
syntax: " @function <dashed-
|
|
4715
|
+
syntax: " @function <dashed-function> <function-parameter>#?) [returns <css-type>]? { <declaration-rule-list> }"
|
|
4716
|
+
},
|
|
4717
|
+
"@mixin": {
|
|
4718
|
+
syntax: " @mixin [<dashed-function> <function-parameter>#? ) | <ident-token> ]{<block-contents>}"
|
|
4719
|
+
},
|
|
4720
|
+
"@apply": {
|
|
4721
|
+
syntax: " @apply [ <dashed-ident> | <dashed-function> ] [ { <declaration-list> } ]?;"
|
|
4716
4722
|
},
|
|
4717
4723
|
"@left-top": {
|
|
4718
4724
|
syntax: " @left-top { <declaration-list> }"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.7.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { PropertyList } from '../../parser/declaration/list.js';
|
|
@@ -37,32 +37,49 @@ class ComputeShorthandFeature {
|
|
|
37
37
|
let l;
|
|
38
38
|
const rules = [];
|
|
39
39
|
const declarations = [];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
let doNotSort = false;
|
|
41
|
+
if (ast.typ == EnumToken.AtRuleNodeType) {
|
|
42
|
+
switch (ast.nam) {
|
|
43
|
+
case "function":
|
|
44
|
+
case "mixin":
|
|
45
|
+
doNotSort = true;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// https://drafts.csswg.org/css-mixins/#:~:text=The%20value%20of%20the%20result%20descriptor%20is%20always%2016px%20in%20the%20above%20example
|
|
50
|
+
if (doNotSort) {
|
|
51
|
+
for (const node of ast.chi) {
|
|
52
|
+
declarations.push(node);
|
|
52
53
|
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
53
56
|
// @ts-ignore
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
for (; k < j; k++) {
|
|
58
|
+
l = k;
|
|
59
|
+
// capture comments with the next token
|
|
60
|
+
while (l + 1 < j) {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
const node = ast.chi[l];
|
|
63
|
+
if (node.typ == EnumToken.CommentNodeType) {
|
|
64
|
+
l++;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
58
68
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
const node = ast.chi[l];
|
|
71
|
+
if (node.typ == EnumToken.DeclarationNodeType) {
|
|
72
|
+
for (let m = k; m <= l; m++) {
|
|
73
|
+
declarations.push(ast.chi[m]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (let m = k; m <= l; m++) {
|
|
78
|
+
rules.push(ast.chi[m]);
|
|
79
|
+
}
|
|
63
80
|
}
|
|
81
|
+
k = l;
|
|
64
82
|
}
|
|
65
|
-
k = l;
|
|
66
83
|
}
|
|
67
84
|
if (declarations.length > 0) {
|
|
68
85
|
ast.chi.length = 0;
|
package/dist/src/lib/ast/find.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.7.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { eq } from '../parser/utils/eq.js';
|
|
@@ -17,6 +17,7 @@ import { TOKENS, PARENT, OPTIMIZED, RAW, combinators, LOCEND, LOCSTA, LOCSRCID }
|
|
|
17
17
|
import { replaceNodeOrValue } from '../parser/utils/token.js';
|
|
18
18
|
import { parseString } from '../parser/parse.js';
|
|
19
19
|
import { replaceCompound } from './expand.js';
|
|
20
|
+
import { equalsIgnoreCase } from '../parser/utils/text.js';
|
|
20
21
|
|
|
21
22
|
const notEndingWith = ["(", "["].concat(combinators);
|
|
22
23
|
const rules = [
|
|
@@ -366,8 +367,35 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
|
|
|
366
367
|
previous = ast.chi[--nodeIndex];
|
|
367
368
|
}
|
|
368
369
|
node = ast.chi[i];
|
|
369
|
-
if (node.typ === EnumToken.AtRuleNodeType
|
|
370
|
-
|
|
370
|
+
if (node.typ === EnumToken.AtRuleNodeType) {
|
|
371
|
+
if (node.nam === "font-face") {
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
// https://drafts.csswg.org/css-mixins/#:~:text=The%20value%20of%20the%20result%20descriptor%20is%20always%2016px%20in%20the%20above%20example
|
|
375
|
+
if (equalsIgnoreCase(node.nam, "function")) {
|
|
376
|
+
const chi = node.chi;
|
|
377
|
+
let k = chi?.length;
|
|
378
|
+
let slice = false;
|
|
379
|
+
while (k--) {
|
|
380
|
+
if (chi[k].typ === EnumToken.CommentNodeType ||
|
|
381
|
+
chi[k].typ === EnumToken.WhitespaceTokenType) {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (chi[k].typ === EnumToken.DeclarationNodeType &&
|
|
385
|
+
equalsIgnoreCase(chi[k].nam, "result")) {
|
|
386
|
+
slice = true;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (k > 0 && slice) {
|
|
391
|
+
while (k--) {
|
|
392
|
+
if (chi[k].typ === EnumToken.AtRuleNodeType) {
|
|
393
|
+
chi.splice(k, 1);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
371
399
|
}
|
|
372
400
|
if (node.typ === EnumToken.KeyframesAtRuleNodeType) {
|
|
373
401
|
if (previous?.typ === EnumToken.KeyframesAtRuleNodeType &&
|
package/dist/src/lib/ast/node.js
CHANGED
package/dist/src/lib/ast/walk.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.7.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { PropertySet } from './set.js';
|
|
@@ -33,6 +33,16 @@ class PropertyList {
|
|
|
33
33
|
let result;
|
|
34
34
|
for (const declaration of declarations) {
|
|
35
35
|
name = declaration.typ != EnumToken.DeclarationNodeType ? null : declaration.nam;
|
|
36
|
+
// do not compute shorthand for invalid declarations
|
|
37
|
+
if (name == null) {
|
|
38
|
+
this.declarations.set(objectHash(declaration), declaration);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
// @functiom / result
|
|
42
|
+
if (declaration[STATE] & EnumAstNodeStatus.Unknown && equalsIgnoreCase("result", name)) {
|
|
43
|
+
this.declarations.set(declaration.nam, declaration);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
36
46
|
if (declaration[STATE] &
|
|
37
47
|
(EnumAstNodeStatus.Invalid | EnumAstNodeStatus.Unknown | EnumAstNodeStatus.ValidationFailed) ||
|
|
38
48
|
declaration.typ != EnumToken.DeclarationNodeType ||
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.7.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { eq } from '../utils/eq.js';
|
|
@@ -206,7 +206,7 @@ class PropertyMap {
|
|
|
206
206
|
if (value instanceof PropertyMap) {
|
|
207
207
|
for (const [k, v] of value.declarations) {
|
|
208
208
|
if (k == value.config.shorthand) {
|
|
209
|
-
for (const [key
|
|
209
|
+
for (const [key] of Object.entries(value.config.properties)) {
|
|
210
210
|
mapped[key] = cloneNode(v);
|
|
211
211
|
for (let i = 0; i < v.val.length; i++) {
|
|
212
212
|
// @ts-ignore
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.7.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { isIdentColor, parseColor, isColor } from '../syntax/syntax.js';
|
|
@@ -324,19 +324,10 @@ function parseVisitors(visitorsDef, errors) {
|
|
|
324
324
|
key = visitors[i][0];
|
|
325
325
|
value = visitors[i][1];
|
|
326
326
|
if (Number.isInteger(+key)) {
|
|
327
|
-
// if (Array.isArray(value)) {
|
|
328
|
-
// visitors.splice(i + 1, 0, ...Object.entries(value));
|
|
329
|
-
// continue;
|
|
330
|
-
// }
|
|
331
327
|
if (typeof value == "function") {
|
|
332
328
|
key = value.name;
|
|
333
329
|
}
|
|
334
330
|
}
|
|
335
|
-
// if (Array.isArray(value)) {
|
|
336
|
-
// // @ts-ignore
|
|
337
|
-
// visitors.splice(i + 1, 0, ...value.map((item) => [key, item]));
|
|
338
|
-
// continue;
|
|
339
|
-
// }
|
|
340
331
|
if (key in EnumToken) {
|
|
341
332
|
if (typeof value == "function") {
|
|
342
333
|
if (!valuesHandlers.has(EnumToken[key])) {
|
|
@@ -696,7 +687,7 @@ function doParseSync(tokenizer, options = {}) {
|
|
|
696
687
|
if (tokens.length > 0) {
|
|
697
688
|
node = parseNode(tokens, context, options, errors, stats, invalidNodes);
|
|
698
689
|
if (node != null) {
|
|
699
|
-
if ("chi" in node
|
|
690
|
+
if ("chi" in node) {
|
|
700
691
|
stack.push(node);
|
|
701
692
|
context = node;
|
|
702
693
|
}
|
|
@@ -1468,14 +1459,9 @@ async function doParse(iter, options = {}) {
|
|
|
1468
1459
|
let parensMatch = 0;
|
|
1469
1460
|
let curlyBracketMatch = 0;
|
|
1470
1461
|
let tokenizer = iter instanceof Promise ? await iter : iter;
|
|
1471
|
-
// ast[ROOT] = ast;
|
|
1472
1462
|
ast[LOCSRCID] = options.source.id;
|
|
1473
1463
|
ast[LOCSTA] = 0;
|
|
1474
1464
|
ast[LOCEND] = 0;
|
|
1475
|
-
// if (Array.isArray(iter)) {
|
|
1476
|
-
// // @ts-expect-error
|
|
1477
|
-
// iter = iter[Symbol.iterator]() as Iterator<TokenizeResult>;
|
|
1478
|
-
// }
|
|
1479
1465
|
while (!tokenizer.done()) {
|
|
1480
1466
|
tokenizer.next();
|
|
1481
1467
|
if (tokenizer.unit != null) {
|
|
@@ -1716,6 +1702,11 @@ async function doParse(iter, options = {}) {
|
|
|
1716
1702
|
case EnumToken.AtRuleNodeType:
|
|
1717
1703
|
case EnumToken.KeyframesRuleNodeType:
|
|
1718
1704
|
case EnumToken.KeyframesAtRuleNodeType:
|
|
1705
|
+
if (nodes[i][TOKENS] == null) {
|
|
1706
|
+
if (nodes[i].typ == EnumToken.RuleNodeType) {
|
|
1707
|
+
nodes[i][TOKENS] = parseString(nodes[i].sel);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1719
1710
|
for (const token of nodes[i][TOKENS]) {
|
|
1720
1711
|
subNodes.push(token);
|
|
1721
1712
|
}
|
|
@@ -2710,7 +2701,7 @@ function parseAtRule(stream, context, options, errors, parseAsBlock = null) {
|
|
|
2710
2701
|
else if (context.typ === EnumToken.AtRuleNodeType &&
|
|
2711
2702
|
"page" === context.nam &&
|
|
2712
2703
|
pageMarginBoxType.has(atRuleName.toLowerCase())) {
|
|
2713
|
-
if (parseAsBlock === false) {
|
|
2704
|
+
if (parseAsBlock === false && syntaxRules.optionalBody === false) {
|
|
2714
2705
|
errors.push({
|
|
2715
2706
|
action: "drop",
|
|
2716
2707
|
node: atRule,
|
|
@@ -2749,7 +2740,7 @@ function parseAtRule(stream, context, options, errors, parseAsBlock = null) {
|
|
|
2749
2740
|
if (parseAsBlock === null) {
|
|
2750
2741
|
parseAsBlock = blockAllowed;
|
|
2751
2742
|
}
|
|
2752
|
-
if (syntax != null && atRule.nam !== "layer" && parseAsBlock !== blockAllowed) {
|
|
2743
|
+
if (syntax != null && atRule.nam !== "layer" && parseAsBlock !== blockAllowed && !syntaxRules.optionalBody) {
|
|
2753
2744
|
errors.push({
|
|
2754
2745
|
action: "drop",
|
|
2755
2746
|
node: atRule,
|