Skip to content

Commit 8867bc3

Browse files
authored
update css-tree@^1.1.2 (#5958)
1 parent 44f41c9 commit 8867bc3

File tree

5 files changed

+30
-27
lines changed

5 files changed

+30
-27
lines changed

package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"c8": "^5.0.1",
113113
"code-red": "^0.1.4",
114114
"codecov": "^3.5.0",
115-
"css-tree": "1.0.0-alpha22",
115+
"css-tree": "^1.1.2",
116116
"eslint": "^7.15.0",
117117
"eslint-plugin-import": "^2.22.1",
118118
"eslint-plugin-svelte3": "^2.7.3",

src/compiler/compile/css/Stylesheet.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Rule {
4747
constructor(node: CssNode, stylesheet, parent?: Atrule) {
4848
this.node = node;
4949
this.parent = parent;
50-
this.selectors = node.selector.children.map((node: CssNode) => new Selector(node, stylesheet));
50+
this.selectors = node.prelude.children.map((node: CssNode) => new Selector(node, stylesheet));
5151
this.declarations = node.block.children.map((node: CssNode) => new Declaration(node));
5252
}
5353

@@ -182,29 +182,29 @@ class Atrule {
182182

183183
minify(code: MagicString, dev: boolean) {
184184
if (this.node.name === 'media') {
185-
const expression_char = code.original[this.node.expression.start];
185+
const expression_char = code.original[this.node.prelude.start];
186186
let c = this.node.start + (expression_char === '(' ? 6 : 7);
187-
if (this.node.expression.start > c) code.remove(c, this.node.expression.start);
187+
if (this.node.prelude.start > c) code.remove(c, this.node.prelude.start);
188188

189-
this.node.expression.children.forEach((query: CssNode) => {
189+
this.node.prelude.children.forEach((query: CssNode) => {
190190
// TODO minify queries
191191
c = query.end;
192192
});
193193

194194
code.remove(c, this.node.block.start);
195195
} else if (this.node.name === 'supports') {
196196
let c = this.node.start + 9;
197-
if (this.node.expression.start - c > 1) code.overwrite(c, this.node.expression.start, ' ');
198-
this.node.expression.children.forEach((query: CssNode) => {
197+
if (this.node.prelude.start - c > 1) code.overwrite(c, this.node.prelude.start, ' ');
198+
this.node.prelude.children.forEach((query: CssNode) => {
199199
// TODO minify queries
200200
c = query.end;
201201
});
202202
code.remove(c, this.node.block.start);
203203
} else {
204204
let c = this.node.start + this.node.name.length + 1;
205-
if (this.node.expression) {
206-
if (this.node.expression.start - c > 1) code.overwrite(c, this.node.expression.start, ' ');
207-
c = this.node.expression.end;
205+
if (this.node.prelude) {
206+
if (this.node.prelude.start - c > 1) code.overwrite(c, this.node.prelude.start, ' ');
207+
c = this.node.prelude.end;
208208
}
209209
if (this.node.block && this.node.block.start - c > 0) {
210210
code.remove(c, this.node.block.start);
@@ -235,7 +235,7 @@ class Atrule {
235235

236236
transform(code: MagicString, id: string, keyframes: Map<string, string>, max_amount_class_specificity_increased: number) {
237237
if (is_keyframes_node(this.node)) {
238-
this.node.expression.children.forEach(({ type, name, start, end }: CssNode) => {
238+
this.node.prelude.children.forEach(({ type, name, start, end }: CssNode) => {
239239
if (type === 'Identifier') {
240240
if (name.startsWith('-global-')) {
241241
code.remove(start, start + 8);
@@ -317,7 +317,7 @@ export default class Stylesheet {
317317
}
318318

319319
if (is_keyframes_node(node)) {
320-
node.expression.children.forEach((expression: CssNode) => {
320+
node.prelude.children.forEach((expression: CssNode) => {
321321
if (expression.type === 'Identifier' && !expression.name.startsWith('-global-')) {
322322
this.keyframes.set(expression.name, `${this.id}-${expression.name}`);
323323
}

src/compiler/parse/read/style.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ export default function read_style(parser: Parser, start: number, attributes: No
1414
try {
1515
ast = parse(styles, {
1616
positions: true,
17-
offset: content_start
17+
offset: content_start,
18+
onParseError(error) {
19+
throw error;
20+
}
1821
});
1922
} catch (err) {
20-
if (err.name === 'CssSyntaxError') {
23+
if (err.name === 'SyntaxError') {
2124
parser.error({
2225
code: 'css-syntax-error',
2326
message: err.message

test/parser/samples/css/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"children": [
3838
{
3939
"type": "Rule",
40-
"selector": {
40+
"prelude": {
4141
"type": "SelectorList",
4242
"children": [
4343
{
@@ -74,7 +74,7 @@
7474
"end": 43
7575
}
7676
],
77-
"start": 39,
77+
"start": 40,
7878
"end": 43
7979
},
8080
"start": 33,

0 commit comments

Comments
 (0)