mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
feat(css): Added optional css-tree parser (#8076)
* feat(css): Added optional css-tree parser * test: css-tree parser compat tests * test: more css-tree compat tests
This commit is contained in:

committed by
Alexander Vakrilov

parent
f5d6e4f5ed
commit
49a7607f4e
@ -12,6 +12,9 @@ import {
|
||||
CSS3Parser,
|
||||
CSSNativeScript
|
||||
} from "../../css/parser";
|
||||
import {
|
||||
cssTreeParse
|
||||
} from "../../css/css-tree-parser";
|
||||
|
||||
import {
|
||||
RuleSet,
|
||||
@ -50,11 +53,15 @@ function ensureCssAnimationParserModule() {
|
||||
}
|
||||
}
|
||||
|
||||
let parser: "rework" | "nativescript" = "rework";
|
||||
let parser: "rework" | "nativescript" | "css-tree" = "rework";
|
||||
try {
|
||||
const appConfig = require("~/package.json");
|
||||
if (appConfig && appConfig.cssParser === "nativescript") {
|
||||
parser = "nativescript";
|
||||
if (appConfig) {
|
||||
if (appConfig.cssParser === "css-tree") {
|
||||
parser = "css-tree";
|
||||
} else if (appConfig.cssParser === "nativescript") {
|
||||
parser = "nativescript";
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
@ -220,6 +227,10 @@ class CSSSource {
|
||||
private parseCSSAst() {
|
||||
if (this._source) {
|
||||
switch (parser) {
|
||||
case "css-tree":
|
||||
this._ast = cssTreeParse(this._source, this._file);
|
||||
|
||||
return;
|
||||
case "nativescript":
|
||||
const cssparser = new CSS3Parser(this._source);
|
||||
const stylesheet = cssparser.parseAStylesheet();
|
||||
|
Reference in New Issue
Block a user