mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #653 from NathanaelA/Branch_CSS_Lowercase
Changed createSelectorsFromSyntaxTree to use a loop rather than filter.
This commit is contained in:
@ -824,6 +824,25 @@ export function test_set_invalid_CSS_values_dont_cause_crash() {
|
|||||||
}, invalidCSS);
|
}, invalidCSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check Mixed, Upper and lower case properties
|
||||||
|
var casedCSS = ".cased {" +
|
||||||
|
"cOlOr: blue; " +
|
||||||
|
"FONT-SIZE: 30; " +
|
||||||
|
"background-color: red; " +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
export function test_set_mixed_CSS_cases_works() {
|
||||||
|
var testButton = new buttonModule.Button();
|
||||||
|
testButton.text = "Test";
|
||||||
|
testButton.cssClass = "cased";
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(testButton, function (views: Array<viewModule.View>) {
|
||||||
|
TKUnit.assertEqual(30, testButton.style.fontSize);
|
||||||
|
helper.assertViewBackgroundColor(testButton, "#FF0000");
|
||||||
|
helper.assertViewColor(testButton, "#0000FF");
|
||||||
|
}, casedCSS);
|
||||||
|
}
|
||||||
|
|
||||||
// <snippet module="ui/styling" title="styling">
|
// <snippet module="ui/styling" title="styling">
|
||||||
// For information and example how to use style properties please refer to special [**Styling**](../../../styling.md) topic.
|
// For information and example how to use style properties please refer to special [**Styling**](../../../styling.md) topic.
|
||||||
// </snippet>
|
// </snippet>
|
||||||
|
@ -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