update css-tree@^1.1.2 (#5958)

pull/5970/head
Tan Li Hau 4 years ago committed by GitHub
parent 44f41c9edd
commit 8867bc31c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

22
package-lock.json generated

@ -1051,19 +1051,19 @@
}
},
"css-tree": {
"version": "1.0.0-alpha22",
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha22.tgz",
"integrity": "sha1-M4oAbjMce0+dq3tq9Tns5W/3ivI=",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.1.2.tgz",
"integrity": "sha512-wCoWush5Aeo48GLhfHPbmvZs59Z+M7k5+B1xDnXbdWNcEF423DoFdqSWE0PM5aNk5nI5cp1q7ms36zGApY/sKQ==",
"dev": true,
"requires": {
"mdn-data": "^1.0.0",
"source-map": "^0.5.3"
"mdn-data": "2.0.14",
"source-map": "^0.6.1"
},
"dependencies": {
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
@ -2904,9 +2904,9 @@
}
},
"mdn-data": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.2.0.tgz",
"integrity": "sha512-esDqNvsJB2q5V28+u7NdtdMg6Rmg4khQmAVSjUiX7BY/7haIv0K2yWM43hYp0or+3nvG7+UaTF1JHz31hgU1TA==",
"version": "2.0.14",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz",
"integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==",
"dev": true
},
"mem": {

@ -112,7 +112,7 @@
"c8": "^5.0.1",
"code-red": "^0.1.4",
"codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22",
"css-tree": "^1.1.2",
"eslint": "^7.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-svelte3": "^2.7.3",

@ -47,7 +47,7 @@ class Rule {
constructor(node: CssNode, stylesheet, parent?: Atrule) {
this.node = node;
this.parent = parent;
this.selectors = node.selector.children.map((node: CssNode) => new Selector(node, stylesheet));
this.selectors = node.prelude.children.map((node: CssNode) => new Selector(node, stylesheet));
this.declarations = node.block.children.map((node: CssNode) => new Declaration(node));
}
@ -182,11 +182,11 @@ class Atrule {
minify(code: MagicString, dev: boolean) {
if (this.node.name === 'media') {
const expression_char = code.original[this.node.expression.start];
const expression_char = code.original[this.node.prelude.start];
let c = this.node.start + (expression_char === '(' ? 6 : 7);
if (this.node.expression.start > c) code.remove(c, this.node.expression.start);
if (this.node.prelude.start > c) code.remove(c, this.node.prelude.start);
this.node.expression.children.forEach((query: CssNode) => {
this.node.prelude.children.forEach((query: CssNode) => {
// TODO minify queries
c = query.end;
});
@ -194,17 +194,17 @@ class Atrule {
code.remove(c, this.node.block.start);
} else if (this.node.name === 'supports') {
let c = this.node.start + 9;
if (this.node.expression.start - c > 1) code.overwrite(c, this.node.expression.start, ' ');
this.node.expression.children.forEach((query: CssNode) => {
if (this.node.prelude.start - c > 1) code.overwrite(c, this.node.prelude.start, ' ');
this.node.prelude.children.forEach((query: CssNode) => {
// TODO minify queries
c = query.end;
});
code.remove(c, this.node.block.start);
} else {
let c = this.node.start + this.node.name.length + 1;
if (this.node.expression) {
if (this.node.expression.start - c > 1) code.overwrite(c, this.node.expression.start, ' ');
c = this.node.expression.end;
if (this.node.prelude) {
if (this.node.prelude.start - c > 1) code.overwrite(c, this.node.prelude.start, ' ');
c = this.node.prelude.end;
}
if (this.node.block && this.node.block.start - c > 0) {
code.remove(c, this.node.block.start);
@ -235,7 +235,7 @@ class Atrule {
transform(code: MagicString, id: string, keyframes: Map<string, string>, max_amount_class_specificity_increased: number) {
if (is_keyframes_node(this.node)) {
this.node.expression.children.forEach(({ type, name, start, end }: CssNode) => {
this.node.prelude.children.forEach(({ type, name, start, end }: CssNode) => {
if (type === 'Identifier') {
if (name.startsWith('-global-')) {
code.remove(start, start + 8);
@ -317,7 +317,7 @@ export default class Stylesheet {
}
if (is_keyframes_node(node)) {
node.expression.children.forEach((expression: CssNode) => {
node.prelude.children.forEach((expression: CssNode) => {
if (expression.type === 'Identifier' && !expression.name.startsWith('-global-')) {
this.keyframes.set(expression.name, `${this.id}-${expression.name}`);
}

@ -14,10 +14,13 @@ export default function read_style(parser: Parser, start: number, attributes: No
try {
ast = parse(styles, {
positions: true,
offset: content_start
offset: content_start,
onParseError(error) {
throw error;
}
});
} catch (err) {
if (err.name === 'CssSyntaxError') {
if (err.name === 'SyntaxError') {
parser.error({
code: 'css-syntax-error',
message: err.message

@ -37,7 +37,7 @@
"children": [
{
"type": "Rule",
"selector": {
"prelude": {
"type": "SelectorList",
"children": [
{
@ -74,7 +74,7 @@
"end": 43
}
],
"start": 39,
"start": 40,
"end": 43
},
"start": 33,

Loading…
Cancel
Save