pull/9098/head
Nguyen Tran 3 years ago
parent df98c48422
commit 86a9e7459b

@ -1,6 +1,6 @@
// @ts-nocheck
import { fork } from 'css-tree';
import { String, Url, Function, RightParenthesis, Ident, Semicolon } from 'css-tree/tokenizer';
import { String, Url, Function, Ident, Semicolon } from 'css-tree/tokenizer';
import * as node from './node/index.js';
@ -44,31 +44,41 @@ const cqSyntax = fork({
this.skipSC();
if (this.tokenType == Function && this.cmpStr(this.tokenStart, this.tokenEnd, 'layer(')) {
children.push(this.Function(() => {
const children = this.createList();
this.skipSC();
children.push(this.LayerName());
this.skipSC();
return children;
}, this.scope.AtrulePrelude));
} else if (this.tokenType == Ident && this.cmpStr(this.tokenStart, this.tokenEnd, 'layer')) {
children.push(
this.Function(() => {
const children = this.createList();
this.skipSC();
children.push(this.LayerName());
this.skipSC();
return children;
}, this.scope.AtrulePrelude)
);
} else if (
this.tokenType == Ident &&
this.cmpStr(this.tokenStart, this.tokenEnd, 'layer')
) {
children.push(this.Identifier());
}
this.skipSC();
if (this.tokenType == Function && this.cmpStr(this.tokenStart, this.tokenEnd, 'supports(')) {
children.push(this.Function(() => {
const children = this.createList();
this.skipSC();
children.push(this.SupportsCondition());
this.skipSC();
return children;
}, this.scope.AtrulePrelude));
if (
this.tokenType == Function &&
this.cmpStr(this.tokenStart, this.tokenEnd, 'supports(')
) {
children.push(
this.Function(() => {
const children = this.createList();
this.skipSC();
children.push(this.SupportsCondition());
this.skipSC();
return children;
}, this.scope.AtrulePrelude)
);
}
this.skipSC();
if (this.tokenType !== Semicolon) {
children.push(this.MediaQueryList());
}
@ -77,7 +87,7 @@ const cqSyntax = fork({
},
block: null
}
},
}
},
node
});

@ -1,12 +1,12 @@
// @ts-nocheck
import { Delim } from 'css-tree/tokenizer';
const FULLSTOP = 0x002E; // U+002E FULL STOP (.)
const FULLSTOP = 0x002e; // U+002E FULL STOP (.)
export const name = 'LayerName';
export const structure = {
name: 'Identifier',
sublayer: ['LayerName', null],
sublayer: ['LayerName', null]
};
// TODO: Wait for css-tree to support a layer name AST and remove this file
@ -18,8 +18,8 @@ export function parse() {
const char_code = this.charCodeAt(char_idx);
let sublayer;
if (char_code === FULLSTOP) {
this.next();
if (char_code === FULLSTOP) {
this.next();
sublayer = parse.call(this);
} else {
sublayer = null;
@ -29,14 +29,14 @@ export function parse() {
type: 'LayerName',
name,
sublayer,
loc: this.getLocation(start, this.tokenStart),
}
loc: this.getLocation(start, this.tokenStart)
};
}
export function generate(node) {
this.token(Ident, node.name);
this.token(Delim, ".");
this.token(Delim, '.');
if (node.sublayer !== null) {
generate.call(this, node.sublayer);
generate.call(this, node.sublayer);
}
}

@ -1,7 +1,7 @@
// @ts-nocheck
export const name = 'SupportsCondition';
export const structure = {
children: [[]],
children: [[]]
};
// TODO: Wait until css-tree has better @supports condition AST and remove this file
@ -19,4 +19,3 @@ export function parse() {
export function generate(node) {
this.children(node);
}

Loading…
Cancel
Save