From 3eb8514e96c6b44f742aa3a0e657717b40abdc4e Mon Sep 17 00:00:00 2001 From: Nedyalko Nikolov Date: Thu, 7 Apr 2016 17:04:23 +0300 Subject: [PATCH] Fix for using css attribute selector alone. --- apps/tests/ui/style/style-tests.ts | 13 +++++++++++++ ui/styling/css-selector.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/tests/ui/style/style-tests.ts b/apps/tests/ui/style/style-tests.ts index 00d40a222..a61d1b021 100644 --- a/apps/tests/ui/style/style-tests.ts +++ b/apps/tests/ui/style/style-tests.ts @@ -1513,6 +1513,19 @@ export function test_star_attr_selector_incorrect_syntax() { } helper.buildUIAndRunTest(testButton, testFunc, testCss); } + +export function test_alone_attr_selector() { + let testButton = new buttonModule.Button(); + testButton["testAttr"] = "flow"; + + let testCss = "[testAttr*='flower'] { background-color: #FF0000; } button { background-color: #00FF00; }"; + + let testFunc = function (views: Array) { + // style from correct type css should be applied + helper.assertViewBackgroundColor(testButton, "#00FF00"); + } + helper.buildUIAndRunTest(testButton, testFunc, testCss); +} // // For information and example how to use style properties please refer to special [**Styling**](../../../styling.md) topic. // diff --git a/ui/styling/css-selector.ts b/ui/styling/css-selector.ts index f5f20511f..f73888a2b 100644 --- a/ui/styling/css-selector.ts +++ b/ui/styling/css-selector.ts @@ -24,7 +24,7 @@ export class CssSelector { constructor(expression: string, declarations: cssParser.Declaration[]) { if (expression) { let leftSquareBracketIndex = expression.indexOf(LSBRACKET); - if (leftSquareBracketIndex > 0) { + if (leftSquareBracketIndex >= 0) { // extracts what is inside square brackets ([target = 'test'] will extract "target = 'test'") let paramsRegex = /\[\s*(.*)\s*\]/; let attrParams = paramsRegex.exec(expression);