Merge pull request #2994 from NativeScript/apply-css

Don't apply css on unloaded
This commit is contained in:
Alexander Vakrilov
2016-11-01 10:46:29 +02:00
committed by GitHub
7 changed files with 57 additions and 44 deletions

View File

@ -0,0 +1,3 @@
.action {
background-color: red;
}

View File

@ -0,0 +1,5 @@
import frame = require("ui/frame");
export function navigate(args) {
frame.topmost().navigate("ui-tests-app/action-bar/clean");
}

View File

@ -0,0 +1,6 @@
<Page>
<ActionBar title="This is RED" class="action" />
<StackLayout>
<Button text="go to cleared page" tap="navigate"/>
</StackLayout>
</Page>

View File

@ -16,6 +16,7 @@ export function pageLoaded(args: EventData) {
examples.set("actIcons", "action-bar/system-icons");
examples.set("actView", "action-bar/action-view");
examples.set("actionItemPosition", "action-bar/action-item-position");
examples.set("actBGCss", "action-bar/background-css");
let viewModel = new SubMianPageViewModel(wrapLayout, examples);
page.bindingContext = viewModel;

View File

@ -647,8 +647,7 @@ export class View extends ProxyObject implements definition.View {
}
public onUnloaded() {
this._onCssStateChange(this._cssState, null);
this._cssState = null;
this._setCssState(null);
this._unloadEachChildView();
@ -1180,8 +1179,7 @@ export class View extends ProxyObject implements definition.View {
if (!view) {
throw new Error("Expecting a valid View instance.");
}
if(!(view instanceof View))
{
if (!(view instanceof View)) {
throw new Error(view + " is not a valid View instance.");
}
if (view._parent) {
@ -1439,7 +1437,9 @@ export class View extends ProxyObject implements definition.View {
}
// TODO: Make sure the state is set to null and this is called on unloaded to clean up change listeners...
_onCssStateChange(previous: CssState, next: CssState): void {
_setCssState(next: CssState): void {
const previous = this._cssState;
this._cssState = next;
if (!this._invalidateCssHandler) {
this._invalidateCssHandler = () => {

View File

@ -605,7 +605,7 @@ declare module "ui/core/view" {
_domId: number;
_cssState: any /* "ui/styling/style-scope" */;
_onCssStateChange(previous: any /* "ui/styling/style-scope" */, any /* "ui/styling/style-scope" */);
_setCssState(next: any /* "ui/styling/style-scope" */);
_registerAnimation(animation: keyframeAnimationModule.KeyframeAnimation);
_unregisterAnimation(animation: keyframeAnimationModule.KeyframeAnimation);

View File

@ -201,10 +201,8 @@ export class StyleScope {
let state = this._selectors.query(view);
let previousState = view._cssState;
let nextState = new CssState(view, state);
view._cssState = nextState;
view._onCssStateChange(previousState, nextState);
view._setCssState(nextState);
}
public query(node: Node): SelectorCore[] {