mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Changed createSelectorsFromSyntaxTree to use a loop rather than filter.
1. Changed code to lowercase the declaration property 2. Minimize the data pushed to each rule
This commit is contained in:
@@ -200,7 +200,6 @@ export class StyleScope {
|
|||||||
|
|
||||||
var rules = ast.stylesheet.rules;
|
var rules = ast.stylesheet.rules;
|
||||||
var rule: cssParser.Rule;
|
var rule: cssParser.Rule;
|
||||||
var filteredDeclarations: cssParser.Declaration[];
|
|
||||||
var i;
|
var i;
|
||||||
var j;
|
var j;
|
||||||
|
|
||||||
@@ -209,11 +208,25 @@ export class StyleScope {
|
|||||||
rule = rules[i];
|
rule = rules[i];
|
||||||
// Skip comment nodes.
|
// Skip comment nodes.
|
||||||
if (rule.type === "rule") {
|
if (rule.type === "rule") {
|
||||||
|
|
||||||
// Filter comment nodes.
|
// Filter comment nodes.
|
||||||
filteredDeclarations = rule.declarations.filter((val, i, arr) => { return val.type === "declaration" });
|
var filteredDeclarations = [];
|
||||||
for (j = 0; j < rule.selectors.length; j++) {
|
if (rule.declarations) {
|
||||||
result.push(cssSelector.createSelector(rule.selectors[j], filteredDeclarations));
|
for (j = 0; j < rule.declarations.length; j++) {
|
||||||
|
var declaration = rule.declarations[j];
|
||||||
|
if (declaration.type === "declaration") {
|
||||||
|
filteredDeclarations.push({
|
||||||
|
property: declaration.property.toLowerCase(),
|
||||||
|
value: declaration.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < rule.selectors.length; j++) {
|
||||||
|
result.push(cssSelector.createSelector(rule.selectors[j], filteredDeclarations));
|
||||||
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user