Skip to content

Commit d38232f

Browse files
authored
[BREAKING BUGFIX beta] Adds autotracking transaction (#18554)
[BREAKING BUGFIX beta] Adds autotracking transaction
2 parents 7b9f0af + 6282a74 commit d38232f

39 files changed

+765
-539
lines changed

packages/@ember/-internals/glimmer/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export { default as Checkbox } from './lib/components/checkbox';
355355
export { default as TextField } from './lib/components/text-field';
356356
export { default as TextArea } from './lib/components/textarea';
357357
export { default as LinkComponent } from './lib/components/link-to';
358-
export { default as Component, ROOT_REF } from './lib/component';
358+
export { default as Component } from './lib/component';
359359
export { default as Helper, helper } from './lib/helper';
360360
export { default as Environment } from './lib/environment';
361361
export { SafeString, escapeExpression, htmlSafe, isHTMLSafe } from './lib/utils/string';
@@ -385,11 +385,8 @@ export { default as AbstractComponentManager } from './lib/component-managers/ab
385385
// TODO just test these through public API
386386
// a lot of these are testing how a problem was solved
387387
// rather than the problem was solved
388-
// DebugStack should just test the assert message
389-
// it supports for example
390388
export { UpdatableReference, INVOKE } from './lib/utils/references';
391389
export { default as iterableFor } from './lib/utils/iterable';
392-
export { default as getDebugStack, DebugStack } from './lib/utils/debug-stack';
393390
export { default as OutletView } from './lib/views/outlet';
394391
export { capabilities } from './lib/component-managers/custom';
395392
export { setComponentManager, getComponentManager } from './lib/utils/custom-component-manager';

packages/@ember/-internals/glimmer/lib/component-managers/abstract.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,16 @@ import {
1010
PreparedArguments,
1111
} from '@glimmer/runtime';
1212
import { Destroyable, Opaque, Option } from '@glimmer/util';
13-
import { DebugStack } from '../utils/debug-stack';
1413

1514
// implements the ComponentManager interface as defined in glimmer:
1615
// tslint:disable-next-line:max-line-length
1716
// https://github.com/glimmerjs/glimmer-vm/blob/v0.24.0-beta.4/packages/%40glimmer/runtime/lib/component/interfaces.ts#L21
1817

1918
export default abstract class AbstractManager<T, U> implements ComponentManager<T, U> {
20-
public debugStack: DebugStack | undefined = undefined;
21-
2219
prepareArgs(_state: U, _args: Arguments): Option<PreparedArguments> {
2320
return null;
2421
}
2522

26-
// must be implemented by inheritors, inheritors should also
27-
// call `this._pushToDebugStack` to ensure the rerendering
28-
// assertion messages are properly maintained
29-
3023
abstract create(
3124
env: Environment,
3225
definition: U,
@@ -43,9 +36,6 @@ export default abstract class AbstractManager<T, U> implements ComponentManager<
4336
// noop
4437
}
4538

46-
// inheritors should also call `this.debugStack.pop()` to
47-
// ensure the rerendering assertion messages are properly
48-
// maintained
4939
didRenderLayout(_component: T, _bounds: Bounds): void {
5040
// noop
5141
}
@@ -56,16 +46,10 @@ export default abstract class AbstractManager<T, U> implements ComponentManager<
5646

5747
abstract getTag(_bucket: T): Tag;
5848

59-
// inheritors should also call `this._pushToDebugStack`
60-
// to ensure the rerendering assertion messages are
61-
// properly maintained
6249
update(_bucket: T, _dynamicScope: DynamicScope): void {
6350
// noop
6451
}
6552

66-
// inheritors should also call `this.debugStack.pop()` to
67-
// ensure the rerendering assertion messages are properly
68-
// maintained
6953
didUpdateLayout(_bucket: T, _bounds: Bounds): void {
7054
// noop
7155
}

packages/@ember/-internals/glimmer/lib/component-managers/curly.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
WithStaticLayout,
3535
} from '@glimmer/runtime';
3636
import { Destroyable, EMPTY_ARRAY } from '@glimmer/util';
37-
import { BOUNDS, DIRTY_TAG, HAS_BLOCK, IS_DISPATCHING_ATTRS, ROOT_REF } from '../component';
37+
import { BOUNDS, DIRTY_TAG, HAS_BLOCK, IS_DISPATCHING_ATTRS } from '../component';
3838
import Environment from '../environment';
3939
import { DynamicScope } from '../renderer';
4040
import RuntimeResolver from '../resolver';
@@ -48,6 +48,7 @@ import {
4848
} from '../utils/bindings';
4949
import ComponentStateBucket, { Component } from '../utils/curly-component-state-bucket';
5050
import { processComponentArgs } from '../utils/process-args';
51+
import { RootReference } from '../utils/references';
5152
import AbstractManager from './abstract';
5253
import DefinitionState from './definition-state';
5354

@@ -69,6 +70,7 @@ function applyAttributeBindings(
6970
element: Simple.Element,
7071
attributeBindings: Array<string>,
7172
component: Component,
73+
rootRef: RootReference<Component>,
7274
operations: ElementOperations
7375
) {
7476
let seen: string[] = [];
@@ -81,7 +83,7 @@ function applyAttributeBindings(
8183

8284
if (seen.indexOf(attribute) === -1) {
8385
seen.push(attribute);
84-
AttributeBinding.install(element, component, parsed, operations);
86+
AttributeBinding.install(element, component, rootRef, parsed, operations);
8587
}
8688

8789
i--;
@@ -97,7 +99,7 @@ function applyAttributeBindings(
9799
IsVisibleBinding !== undefined &&
98100
seen.indexOf('style') === -1
99101
) {
100-
IsVisibleBinding.install(element, component, operations);
102+
IsVisibleBinding.install(element, component, rootRef, operations);
101103
}
102104
}
103105

@@ -244,10 +246,6 @@ export default class CurlyComponentManager
244246
callerSelfRef: VersionedPathReference,
245247
hasBlock: boolean
246248
): ComponentStateBucket {
247-
if (DEBUG) {
248-
environment.debugStack.push(`component:${state.name}`);
249-
}
250-
251249
// Get the nearest concrete component instance from the scope. "Virtual"
252250
// components will be skipped.
253251
let parentView = dynamicScope.view;
@@ -355,12 +353,12 @@ export default class CurlyComponentManager
355353
return bucket;
356354
}
357355

358-
getSelf({ component }: ComponentStateBucket): VersionedPathReference {
359-
return component[ROOT_REF];
356+
getSelf({ rootRef }: ComponentStateBucket): VersionedPathReference {
357+
return rootRef;
360358
}
361359

362360
didCreateElement(
363-
{ component, classRef, environment }: ComponentStateBucket,
361+
{ component, classRef, environment, rootRef }: ComponentStateBucket,
364362
element: Simple.Element,
365363
operations: ElementOperations
366364
): void {
@@ -370,12 +368,12 @@ export default class CurlyComponentManager
370368
let { attributeBindings, classNames, classNameBindings } = component;
371369

372370
if (attributeBindings && attributeBindings.length) {
373-
applyAttributeBindings(element, attributeBindings, component, operations);
371+
applyAttributeBindings(element, attributeBindings, component, rootRef, operations);
374372
} else {
375373
let id = component.elementId ? component.elementId : guidFor(component);
376374
operations.setAttribute('id', PrimitiveReference.create(id), false, null);
377375
if (EMBER_COMPONENT_IS_VISIBLE && IsVisibleBinding !== undefined) {
378-
IsVisibleBinding.install(element, component, operations);
376+
IsVisibleBinding.install(element, component, rootRef, operations);
379377
}
380378
}
381379

@@ -392,13 +390,13 @@ export default class CurlyComponentManager
392390

393391
if (classNameBindings && classNameBindings.length) {
394392
classNameBindings.forEach((binding: string) => {
395-
ClassNameBinding.install(element, component, binding, operations);
393+
ClassNameBinding.install(element, rootRef, binding, operations);
396394
});
397395
}
398396
operations.setAttribute('class', PrimitiveReference.create('ember-view'), false, null);
399397

400398
if ('ariaRole' in component) {
401-
operations.setAttribute('role', referenceForKey(component, 'ariaRole'), false, null);
399+
operations.setAttribute('role', referenceForKey(rootRef, 'ariaRole'), false, null);
402400
}
403401

404402
component._transitionTo('hasElement');
@@ -415,10 +413,6 @@ export default class CurlyComponentManager
415413
if (ENV._DEBUG_RENDER_TREE) {
416414
bucket.environment.debugRenderTree.didRender(bucket, bounds);
417415
}
418-
419-
if (DEBUG) {
420-
bucket.environment.debugStack.pop();
421-
}
422416
}
423417

424418
getTag({ args, component }: ComponentStateBucket): Tag {
@@ -440,10 +434,6 @@ export default class CurlyComponentManager
440434
environment.debugRenderTree.update(bucket);
441435
}
442436

443-
if (DEBUG) {
444-
environment.debugStack.push(component._debugContainerKey);
445-
}
446-
447437
bucket.finalizer = _instrumentStart('render.component', rerenderInstrumentDetails, component);
448438

449439
if (args && !validate(args.tag, argsRevision)) {
@@ -471,10 +461,6 @@ export default class CurlyComponentManager
471461
if (ENV._DEBUG_RENDER_TREE) {
472462
bucket.environment.debugRenderTree.didRender(bucket, bounds);
473463
}
474-
475-
if (DEBUG) {
476-
bucket.environment.debugStack.pop();
477-
}
478464
}
479465

480466
didUpdate({ component, environment }: ComponentStateBucket): void {

packages/@ember/-internals/glimmer/lib/component-managers/custom.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,12 @@ export default class CustomComponentManager<ComponentInstance>
323323
delegate.getContext(component);
324324
}
325325

326-
getSelf({ delegate, component }: CustomComponentState<ComponentInstance>): PathReference<Opaque> {
327-
return RootReference.create(delegate.getContext(component));
326+
getSelf({
327+
env,
328+
delegate,
329+
component,
330+
}: CustomComponentState<ComponentInstance>): PathReference<Opaque> {
331+
return RootReference.create(delegate.getContext(component), env);
328332
}
329333

330334
getDestructor(state: CustomComponentState<ComponentInstance>): Option<Destroyable> {

packages/@ember/-internals/glimmer/lib/component-managers/input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export default class InputComponentManager extends InternalComponentManager<Inpu
8686
return state;
8787
}
8888

89-
getSelf({ instance }: InputComponentState): VersionedPathReference {
90-
return new RootReference(instance);
89+
getSelf({ env, instance }: InputComponentState): VersionedPathReference {
90+
return new RootReference(instance, env);
9191
}
9292

9393
getTag() {

packages/@ember/-internals/glimmer/lib/component-managers/mount.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ class MountManager extends AbstractManager<EngineState, EngineDefinitionState>
8080
}
8181

8282
create(environment: Environment, { name }: EngineDefinitionState, args: Arguments) {
83-
if (DEBUG) {
84-
environment.debugStack.pushEngine(`engine:${name}`);
85-
}
86-
8783
// TODO
8884
// mount is a runtime helper, this shouldn't use dynamic layout
8985
// we should resolve the engine app template in the helper
@@ -106,12 +102,12 @@ class MountManager extends AbstractManager<EngineState, EngineDefinitionState>
106102

107103
if (modelRef === undefined) {
108104
controller = controllerFactory.create();
109-
self = new RootReference(controller);
105+
self = new RootReference(controller, environment);
110106
bucket = { engine, controller, self, environment };
111107
} else {
112108
let model = modelRef.value();
113109
controller = controllerFactory.create({ model });
114-
self = new RootReference(controller);
110+
self = new RootReference(controller, environment);
115111
bucket = { engine, controller, self, modelRef, environment };
116112
}
117113

@@ -172,10 +168,6 @@ class MountManager extends AbstractManager<EngineState, EngineDefinitionState>
172168
}
173169

174170
didRenderLayout(bucket: EngineState, bounds: Bounds): void {
175-
if (DEBUG) {
176-
bucket.environment.debugStack.pop();
177-
}
178-
179171
if (ENV._DEBUG_RENDER_TREE) {
180172
bucket.environment.debugRenderTree.didRender(bucket.controller, bounds);
181173
bucket.environment.debugRenderTree.didRender(bucket, bounds);

packages/@ember/-internals/glimmer/lib/component-managers/outlet.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { assert } from '@ember/debug';
55
import EngineInstance from '@ember/engine/instance';
66
import { _instrumentStart } from '@ember/instrumentation';
77
import { assign } from '@ember/polyfills';
8-
import { DEBUG } from '@glimmer/env';
98
import { ComponentCapabilities, Option, Simple } from '@glimmer/interfaces';
109
import { CONSTANT_TAG, createTag, Tag, VersionedPathReference } from '@glimmer/reference';
1110
import {
@@ -76,10 +75,6 @@ class OutletComponentManager extends AbstractManager<OutletInstanceState, Outlet
7675
args: Arguments,
7776
dynamicScope: DynamicScope
7877
): OutletInstanceState {
79-
if (DEBUG) {
80-
environment.debugStack.push(`template:${definition.template.referrer.moduleName}`);
81-
}
82-
8378
let parentStateRef = dynamicScope.outletState;
8479
let currentStateRef = definition.ref;
8580

@@ -167,10 +162,6 @@ class OutletComponentManager extends AbstractManager<OutletInstanceState, Outlet
167162
didRenderLayout(state: OutletInstanceState, bounds: Bounds): void {
168163
state.finalize();
169164

170-
if (DEBUG) {
171-
state.environment.debugStack.pop();
172-
}
173-
174165
if (ENV._DEBUG_RENDER_TREE) {
175166
state.environment.debugRenderTree.didRender(state, bounds);
176167

packages/@ember/-internals/glimmer/lib/component-managers/root.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ class RootComponentManager extends CurlyComponentManager {
4040
) {
4141
let component = this.component;
4242

43-
if (DEBUG) {
44-
environment.debugStack.push((component as any)._debugContainerKey);
45-
}
46-
4743
let finalizer = _instrumentStart('render.component', initialRenderInstrumentDetails, component);
4844

4945
dynamicScope.view = component;

packages/@ember/-internals/glimmer/lib/component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import { DEBUG } from '@glimmer/env';
1616
import { createTag, dirty } from '@glimmer/reference';
1717
import { normalizeProperty, SVG_NAMESPACE } from '@glimmer/runtime';
1818

19-
import { RootReference, UPDATE } from './utils/references';
19+
import { UPDATE } from './utils/references';
2020

2121
export const DIRTY_TAG = symbol('DIRTY_TAG');
2222
export const ARGS = symbol('ARGS');
23-
export const ROOT_REF = symbol('ROOT_REF');
2423
export const IS_DISPATCHING_ATTRS = symbol('IS_DISPATCHING_ATTRS');
2524
export const HAS_BLOCK = symbol('HAS_BLOCK');
2625
export const BOUNDS = symbol('BOUNDS');
@@ -722,7 +721,6 @@ const Component = CoreView.extend(
722721
this._super(...arguments);
723722
this[IS_DISPATCHING_ATTRS] = false;
724723
this[DIRTY_TAG] = createTag();
725-
this[ROOT_REF] = new RootReference(this);
726724
this[BOUNDS] = null;
727725

728726
if (DEBUG && this.renderer._destinedForDOM && this.tagName === '') {

packages/@ember/-internals/glimmer/lib/environment.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
SimpleDynamicAttribute,
1111
} from '@glimmer/runtime';
1212
import { Destroyable, Opaque } from '@glimmer/util';
13-
import getDebugStack, { DebugStack } from './utils/debug-stack';
1413
import createIterable from './utils/iterable';
1514
import { ConditionalReference, UpdatableReference } from './utils/references';
1615
import { isHTMLSafe } from './utils/string';
@@ -35,7 +34,6 @@ export default class Environment extends GlimmerEnvironment {
3534
public isInteractive: boolean;
3635
public destroyedComponents: Destroyable[];
3736

38-
private _debugStack: DebugStack | undefined;
3937
private _debugRenderTree: DebugRenderTree | undefined;
4038
public inTransaction = false;
4139

@@ -52,23 +50,11 @@ export default class Environment extends GlimmerEnvironment {
5250

5351
installPlatformSpecificProtocolForURL(this);
5452

55-
if (DEBUG) {
56-
this._debugStack = getDebugStack();
57-
}
58-
5953
if (ENV._DEBUG_RENDER_TREE) {
6054
this._debugRenderTree = new DebugRenderTree();
6155
}
6256
}
6357

64-
get debugStack(): DebugStack {
65-
if (DEBUG) {
66-
return this._debugStack!;
67-
} else {
68-
throw new Error("Can't access debug stack outside of debug mode");
69-
}
70-
}
71-
7258
get debugRenderTree(): DebugRenderTree {
7359
if (ENV._DEBUG_RENDER_TREE) {
7460
return this._debugRenderTree!;

0 commit comments

Comments
 (0)