From fb5c83ee644abd2d60451ce5a42416f7a1321124 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Tue, 6 Sep 2016 23:11:16 -0700 Subject: [PATCH] Make `didCreate` and `didUpdate` post-order See https://github.com/emberjs/ember.js/issues/13972 --- .../glimmer-runtime/lib/compiled/opcodes/component.ts | 9 ++++++--- packages/glimmer-runtime/lib/environment.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/glimmer-runtime/lib/compiled/opcodes/component.ts b/packages/glimmer-runtime/lib/compiled/opcodes/component.ts index b8864515d1..ec9a52d839 100644 --- a/packages/glimmer-runtime/lib/compiled/opcodes/component.ts +++ b/packages/glimmer-runtime/lib/compiled/opcodes/component.ts @@ -69,7 +69,6 @@ export class OpenComponentOpcode extends Opcode { vm.stack().pushSimpleBlock(); vm.pushRootScope(selfRef, layout.symbols); vm.invokeLayout(args, layout, templates, callerScope, component, manager, shadow); - vm.env.didCreate(component, manager); vm.updateWith(new UpdateComponentOpcode(definition.name, component, manager, args, dynamicScope)); } @@ -100,7 +99,6 @@ export class UpdateComponentOpcode extends UpdatingOpcode { let { component, manager, args, dynamicScope } = this; manager.update(component, args, dynamicScope); - vm.env.didUpdate(component, manager); } toJSON(): OpcodeJSON { @@ -167,6 +165,8 @@ export class DidRenderLayoutOpcode extends Opcode { manager.didRenderLayout(component, bounds); + vm.env.didCreate(component, manager); + vm.updateWith(new DidUpdateLayoutOpcode(manager, component, bounds)); } } @@ -183,9 +183,12 @@ export class DidUpdateLayoutOpcode extends UpdatingOpcode { super(); } - evaluate() { + evaluate(vm: UpdatingVM) { let { manager, component, bounds } = this; + manager.didUpdateLayout(component, bounds); + + vm.env.didUpdate(component, manager); } } diff --git a/packages/glimmer-runtime/lib/environment.ts b/packages/glimmer-runtime/lib/environment.ts index 9f6f3e31d6..3d4d04344a 100644 --- a/packages/glimmer-runtime/lib/environment.ts +++ b/packages/glimmer-runtime/lib/environment.ts @@ -207,7 +207,7 @@ export abstract class Environment { manager.didCreate(component); } - for (let i=this.updatedComponents.length-1; i>=0; i--) { + for (let i=0; i