mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix: the css parser should handle empty nodes (#8503)
This commit is contained in:
@ -39,7 +39,7 @@ function transformAst(node, css, type = null) {
|
||||
return {
|
||||
type: "stylesheet",
|
||||
stylesheet: {
|
||||
rules: node.children.map(child => transformAst(child, css)).toArray(),
|
||||
rules: node.children.map(child => transformAst(child, css)).filter(child => child !== null).toArray(),
|
||||
parsingErrors: []
|
||||
}
|
||||
};
|
||||
@ -78,7 +78,7 @@ function transformAst(node, css, type = null) {
|
||||
}
|
||||
|
||||
if (node.type === "Block") {
|
||||
return node.children.map(child => transformAst(child, css, type)).toArray();
|
||||
return node.children.map(child => transformAst(child, css, type)).filter(child => child !== null).toArray();
|
||||
}
|
||||
|
||||
if (node.type === "Rule") {
|
||||
@ -116,6 +116,10 @@ function transformAst(node, css, type = null) {
|
||||
};
|
||||
}
|
||||
|
||||
if (node.type === "Raw") {
|
||||
return null;
|
||||
}
|
||||
|
||||
throw Error(`Unknown node type ${node.type}`);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user