From cdac829c257e37db4da0ee8b75c81b587959e9c0 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Tue, 1 Sep 2015 04:01:47 -0500 Subject: [PATCH 1/3] 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 --- ui/styling/style-scope.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/styling/style-scope.ts b/ui/styling/style-scope.ts index 62cbdf198..ab7262733 100644 --- a/ui/styling/style-scope.ts +++ b/ui/styling/style-scope.ts @@ -200,7 +200,6 @@ export class StyleScope { var rules = ast.stylesheet.rules; var rule: cssParser.Rule; - var filteredDeclarations: cssParser.Declaration[]; var i; var j; @@ -209,11 +208,25 @@ export class StyleScope { rule = rules[i]; // Skip comment nodes. if (rule.type === "rule") { + // Filter comment nodes. - filteredDeclarations = rule.declarations.filter((val, i, arr) => { return val.type === "declaration" }); - for (j = 0; j < rule.selectors.length; j++) { - result.push(cssSelector.createSelector(rule.selectors[j], filteredDeclarations)); + var filteredDeclarations = []; + if (rule.declarations) { + 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)); + } + //} } } From 31c03d3d52ac943fcab43e9f6ef85eb1ccd82625 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Tue, 1 Sep 2015 13:15:47 -0500 Subject: [PATCH 2/3] Added a style test to test mixed, upper and lower case property names. --- apps/tests/ui/style/style-tests.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/tests/ui/style/style-tests.ts b/apps/tests/ui/style/style-tests.ts index f389725f3..ab3e978be 100644 --- a/apps/tests/ui/style/style-tests.ts +++ b/apps/tests/ui/style/style-tests.ts @@ -816,6 +816,26 @@ export function test_set_invalid_CSS_values_dont_cause_crash() { }, 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) { + TKUnit.assertEqual(30, testButton.style.fontSize); + helper.assertViewBackgroundColor(testButton, "#FF0000"); + helper.assertViewColor(testButton, "#0000FF"); + }, casedCSS); +} + + // // For information and example how to use style properties please refer to special [**Styling**](../../../styling.md) topic. // From d6a6b34e8ff81828a68e760c54746560c967ca27 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Thu, 10 Sep 2015 13:04:22 -0500 Subject: [PATCH 3/3] Deleted Extra Blank Line --- apps/tests/ui/style/style-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/tests/ui/style/style-tests.ts b/apps/tests/ui/style/style-tests.ts index ab3e978be..58e067f03 100644 --- a/apps/tests/ui/style/style-tests.ts +++ b/apps/tests/ui/style/style-tests.ts @@ -835,7 +835,6 @@ export function test_set_mixed_CSS_cases_works() { }, casedCSS); } - // // For information and example how to use style properties please refer to special [**Styling**](../../../styling.md) topic. //