Fixed issue #1655 cascading css selectors.

This commit is contained in:
Nedyalko Nikolov
2016-06-16 09:38:13 +03:00
parent a95d8c5c32
commit 7fbfc92155
2 changed files with 21 additions and 0 deletions

View File

@ -1426,6 +1426,23 @@ export function test_UsingSameSelectorsWithSpecific_ShouldApplyLatest() {
} }
helper.buildUIAndRunTest(testButton, testFunc, testCss); helper.buildUIAndRunTest(testButton, testFunc, testCss);
} }
export function test_CascadingClassNamesAppliesAfterPageLoad() {
const stack = new stackModule.StackLayout();
const label = new labelModule.Label();
label.text = "Some text";
label.cssClass = 'lab1';
stack.addChild(label);
application.addCss(".added { background-color: red; } .added .lab1 { background-color: blue; } .lab1 { color: red}");
helper.buildUIAndRunTest(stack, function (views: Array<viewModule.View>) {
helper.assertViewColor(label, "#FF0000");
stack.className = "added";
helper.assertViewBackgroundColor(label, "#0000FF");
helper.assertViewBackgroundColor(stack, "#FF0000");
});
}
// <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>

View File

@ -614,6 +614,10 @@ export class View extends ProxyObject implements definition.View {
if (metadata.affectsStyle) { if (metadata.affectsStyle) {
this.style._resetCssValues(); this.style._resetCssValues();
this._applyStyleFromScope(); this._applyStyleFromScope();
this._eachChildView((v) => {
v._checkMetadataOnPropertyChanged(metadata);
return true;
});
} }
} }