Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions dist/index-umd-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@
*/
exports.ValidationLevel = void 0;
(function (ValidationLevel) {
/**
* disable validation
*/
ValidationLevel[ValidationLevel["None"] = 0] = "None";
/**
* validate selectors and at-rules
*/
ValidationLevel[ValidationLevel["Default"] = 1] = "Default";
/**
* validate selectors, at-rules and declarations
*/
ValidationLevel[ValidationLevel["All"] = 2] = "All"; // selectors + at-rules + declarations
})(exports.ValidationLevel || (exports.ValidationLevel = {}));
/**
Expand Down Expand Up @@ -20923,8 +20932,7 @@
}
let rule = selector.map(s => {
if (s[0] == '&') {
// @ts-ignore
s[0] = node.optimized.optimized[0];
s.splice(0, 1, ...node.optimized.optimized);
}
return s.join('');
}).join(',');
Expand Down
12 changes: 10 additions & 2 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ var SyntaxValidationResult;
*/
exports.ValidationLevel = void 0;
(function (ValidationLevel) {
/**
* disable validation
*/
ValidationLevel[ValidationLevel["None"] = 0] = "None";
/**
* validate selectors and at-rules
*/
ValidationLevel[ValidationLevel["Default"] = 1] = "Default";
/**
* validate selectors, at-rules and declarations
*/
ValidationLevel[ValidationLevel["All"] = 2] = "All"; // selectors + at-rules + declarations
})(exports.ValidationLevel || (exports.ValidationLevel = {}));
/**
Expand Down Expand Up @@ -21032,8 +21041,7 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
}
let rule = selector.map(s => {
if (s[0] == '&') {
// @ts-ignore
s[0] = node.optimized.optimized[0];
s.splice(0, 1, ...node.optimized.optimized);
}
return s.join('');
}).join(',');
Expand Down
12 changes: 11 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
* validation level enum
*/
declare enum ValidationLevel {
/**
* disable validation
*/
None = 0,
/**
* validate selectors and at-rules
*/
Default = 1,// selectors + at-rules
/**
* validate selectors, at-rules and declarations
*/
All = 2
}
/**
Expand Down Expand Up @@ -1160,6 +1169,8 @@ interface ValidationOptions {
interface MinifyOptions {

minify?: boolean;
parseColor?: boolean;
convertColor?: boolean;
nestingRules?: boolean;
expandNestingRules?: boolean;
removeDuplicateDeclarations?: boolean;
Expand All @@ -1179,7 +1190,6 @@ export declare interface ParserOptions extends MinifyOptions, MinifyFeatureOptio
resolveUrls?: boolean;
resolveImport?: boolean;
cwd?: string;
parseColor?: boolean;
removePrefix?: boolean;
load?: (url: string, currentUrl: string) => Promise<string>;
dirname?: (path: string) => string;
Expand Down
3 changes: 1 addition & 2 deletions dist/lib/ast/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
}
let rule = selector.map(s => {
if (s[0] == '&') {
// @ts-ignore
s[0] = node.optimized.optimized[0];
s.splice(0, 1, ...node.optimized.optimized);
}
return s.join('');
}).join(',');
Expand Down
9 changes: 9 additions & 0 deletions dist/lib/ast/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ var SyntaxValidationResult;
*/
var ValidationLevel;
(function (ValidationLevel) {
/**
* disable validation
*/
ValidationLevel[ValidationLevel["None"] = 0] = "None";
/**
* validate selectors and at-rules
*/
ValidationLevel[ValidationLevel["Default"] = 1] = "Default";
/**
* validate selectors, at-rules and declarations
*/
ValidationLevel[ValidationLevel["All"] = 2] = "All"; // selectors + at-rules + declarations
})(ValidationLevel || (ValidationLevel = {}));
/**
Expand Down
5 changes: 2 additions & 3 deletions src/lib/ast/minify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ function doMinify(ast: AstNode, options: ParserOptions = {}, recursive: boolean
return acc;

}, []);

``
if (!wrap) {

wrap = selector.some((s: string[]) => s[0] != '&');
Expand All @@ -497,8 +497,7 @@ function doMinify(ast: AstNode, options: ParserOptions = {}, recursive: boolean

if (s[0] == '&') {

// @ts-ignore
s[0] = node.optimized.optimized[0];
s.splice(0, 1, ...(node as AstRule)!.optimized!.optimized);
}

return s.join('');
Expand Down
23 changes: 23 additions & 0 deletions test/specs/code/nesting.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,29 @@ article {
expandNestingRules: false
}).then(result => expect(result.code).equals(`article{color:red;&{color:blue}&{color:green}}`));
});

it('no nested rules #25', function () {

const css = `

table.colortable td.c {
text-transform:uppercase;
}
table.colortable td:first-child, table.colortable td:first-child+td {
border:1px solid black;
}
`;

return transform(css, {
beautify: true,
nestingRules: false
}).then(result => expect(result.code).equals(`table.colortable td.c {
text-transform: uppercase
}
table.colortable td:first-child,table.colortable td:first-child+td {
border: 1px solid #000
}`));
});
});

}