diff --git a/packages/compiler/src/render3/r3_identifiers.ts b/packages/compiler/src/render3/r3_identifiers.ts index 9ef6b254e4..09a4a4a0fe 100644 --- a/packages/compiler/src/render3/r3_identifiers.ts +++ b/packages/compiler/src/render3/r3_identifiers.ts @@ -63,7 +63,7 @@ export class Identifiers { static interpolation8: o.ExternalReference = {name: 'ɵi8', moduleName: CORE}; static interpolationV: o.ExternalReference = {name: 'ɵiV', moduleName: CORE}; - static memory: o.ExternalReference = {name: 'ɵm', moduleName: CORE}; + static load: o.ExternalReference = {name: 'ɵld', moduleName: CORE}; static projection: o.ExternalReference = {name: 'ɵP', moduleName: CORE}; static projectionDef: o.ExternalReference = {name: 'ɵpD', moduleName: CORE}; diff --git a/packages/compiler/src/render3/r3_view_compiler.ts b/packages/compiler/src/render3/r3_view_compiler.ts index a29e2bb289..0b4cc16284 100644 --- a/packages/compiler/src/render3/r3_view_compiler.ts +++ b/packages/compiler/src/render3/r3_view_compiler.ts @@ -408,7 +408,7 @@ class TemplateDefinitionBuilder implements TemplateAstVisitor, LocalResolver { // Generate the update temporary. const variableName = this.bindingScope.freshReferenceName(); this._bindingMode.push(o.variable(variableName, o.INFERRED_TYPE) - .set(o.importExpr(R3.memory).callFn([o.literal(slot)])) + .set(o.importExpr(R3.load).callFn([o.literal(slot)])) .toDeclStmt(o.INFERRED_TYPE, [o.StmtModifier.Final])); this.bindingScope.set(reference.name, variableName); return [reference.name, reference.originalValue]; diff --git a/packages/compiler/test/render3/r3_view_compiler_spec.ts b/packages/compiler/test/render3/r3_view_compiler_spec.ts index af67ced7cd..619b0c58e3 100644 --- a/packages/compiler/test/render3/r3_view_compiler_spec.ts +++ b/packages/compiler/test/render3/r3_view_compiler_spec.ts @@ -293,7 +293,7 @@ describe('r3_view_compiler', () => { $r3$.ɵC(2, $c2$, MyComponent_IfDirective_Template_2); $r3$.ɵe(); } - const $foo$ = $r3$.ɵm(1); + const $foo$ = $r3$.ɵld(1); IfDirective.ngDirectiveDef.h(3,2); $r3$.ɵcR(2); $r3$.ɵr(3,2); @@ -420,7 +420,7 @@ describe('r3_view_compiler', () => { $r3$.ɵe(); $r3$.ɵT(2); } - const $user$ = $r3$.ɵm(1); + const $user$ = $r3$.ɵld(1); $r3$.ɵt(2, $r3$.ɵi1('Hello ', $user$.value, '!')); } }); diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts index 7b63931092..ce3eb7b51c 100644 --- a/packages/core/src/core_render3_private_export.ts +++ b/packages/core/src/core_render3_private_export.ts @@ -65,7 +65,8 @@ export { t as ɵt, v as ɵv, r as ɵr, - m as ɵm, + st as ɵst, + ld as ɵld, Pp as ɵPp, } from './render3/index'; // clang-format on diff --git a/packages/core/src/render3/index.ts b/packages/core/src/render3/index.ts index 670c2da610..d0dedb3da9 100644 --- a/packages/core/src/render3/index.ts +++ b/packages/core/src/render3/index.ts @@ -53,7 +53,8 @@ export { elementStyle as s, listener as L, - memory as m, + store as st, + load as ld, projection as P, projectionDef as pD, diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index d22ec58195..88ebe235d6 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -1306,8 +1306,7 @@ export function projection( const componentNode = findComponentHost(currentView); // make sure that nodes to project were memorized - const nodesForSelector = - valueInData(componentNode.data !.data !, localIndex)[selectorIndex]; + const nodesForSelector = componentNode.data !.data ![localIndex][selectorIndex]; // build the linked list of projected nodes: for (let i = 0; i < nodesForSelector.length; i++) { @@ -1744,23 +1743,20 @@ export function interpolation8( NO_CHANGE; } -export function memory(index: number, value?: T): T { - return valueInData(data, index, value); +/** Store a value in the `data` at a given `index`. */ +export function store(index: number, value: T): void { + // We don't store any static data for local variables, so the first time + // we see the template, we should store as null to avoid a sparse array + if (index >= tData.length) { + tData[index] = null; + } + data[index] = value; } -function valueInData(data: any[], index: number, value?: T): T { - if (value === undefined) { - ngDevMode && assertDataInRange(index, data); - value = data[index]; - } else { - // We don't store any static data for local variables, so the first time - // we see the template, we should store as null to avoid a sparse array - if (index >= tData.length) { - tData[index] = null; - } - data[index] = value; - } - return value !; +/** Retrieves a value from the `data`. */ +export function load(index: number): T { + ngDevMode && assertDataInRange(index, data); + return data[index]; } export function getCurrentQueries(QueryType: {new (): LQueries}): LQueries { diff --git a/packages/core/src/render3/query.ts b/packages/core/src/render3/query.ts index 63afa798db..610d1983df 100644 --- a/packages/core/src/render3/query.ts +++ b/packages/core/src/render3/query.ts @@ -17,7 +17,7 @@ import {getSymbolIterator} from '../util'; import {assertEqual, assertNotNull} from './assert'; import {ReadFromInjectorFn, getOrCreateNodeInjectorForNode} from './di'; -import {assertPreviousIsParent, getCurrentQueries, memory} from './instructions'; +import {assertPreviousIsParent, getCurrentQueries, store} from './instructions'; import {DirectiveDef, unusedValueExportToPlacateAjd as unused1} from './interfaces/definition'; import {LInjector, unusedValueExportToPlacateAjd as unused2} from './interfaces/injector'; import {LContainerNode, LElementNode, LNode, LNodeFlags, TNode, unusedValueExportToPlacateAjd as unused3} from './interfaces/node'; @@ -389,7 +389,7 @@ export function query( queries.track(queryList, predicate, descend, read); if (memoryIndex != null) { - memory(memoryIndex, queryList); + store(memoryIndex, queryList); } return queryList; } diff --git a/packages/core/test/render3/common_with_def.ts b/packages/core/test/render3/common_with_def.ts index 1ee4871176..06feef5f1c 100644 --- a/packages/core/test/render3/common_with_def.ts +++ b/packages/core/test/render3/common_with_def.ts @@ -11,7 +11,6 @@ import {IterableDiffers} from '@angular/core'; import {defaultIterableDiffers} from '../../src/change_detection/change_detection'; import {DirectiveType, InjectFlags, NgOnChangesFeature, defineDirective, inject, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index'; -import {memory} from '../../src/render3/instructions'; export const NgForOf: DirectiveType> = NgForOfDef as any; diff --git a/packages/core/test/render3/compiler_canonical/compiler_canonical_spec.ts b/packages/core/test/render3/compiler_canonical/compiler_canonical_spec.ts index 264ab8a649..3484a047a0 100644 --- a/packages/core/test/render3/compiler_canonical/compiler_canonical_spec.ts +++ b/packages/core/test/render3/compiler_canonical/compiler_canonical_spec.ts @@ -354,7 +354,7 @@ describe('compiler specification', () => { $r3$.ɵC(2, $c1_dirs$, C1); $r3$.ɵe(); } - let $foo$ = $r3$.ɵm(1); + let $foo$ = $r3$.ɵld(1); $r3$.ɵcR(2); $r3$.ɵr(3, 2); $r3$.ɵcr(); @@ -951,8 +951,8 @@ describe('compiler specification', () => { $r3$.ɵe(); } - $r3$.ɵqR($tmp$ = $r3$.ɵm>(0)) && (ctx.someDir = $tmp$.first); - $r3$.ɵqR($tmp$ = $r3$.ɵm>(1)) && + $r3$.ɵqR($tmp$ = $r3$.ɵld>(0)) && (ctx.someDir = $tmp$.first); + $r3$.ɵqR($tmp$ = $r3$.ɵld>(1)) && (ctx.someDirList = $tmp$ as QueryList); SomeDirective.ngDirectiveDef.h(3, 2); $r3$.ɵr(3, 2); @@ -998,9 +998,9 @@ describe('compiler specification', () => { hostBindings: function ContentQueryComponent_HostBindings( dirIndex: $number$, elIndex: $number$) { let $tmp$: any; - const $instance$ = $r3$.ɵm(dirIndex)[0]; - $r3$.ɵqR($tmp$ = $r3$.ɵm(dirIndex)[1]) && ($instance$.someDir = $tmp$.first); - $r3$.ɵqR($tmp$ = $r3$.ɵm(dirIndex)[2]) && ($instance$.someDirList = $tmp$); + const $instance$ = $r3$.ɵld(dirIndex)[0]; + $r3$.ɵqR($tmp$ = $r3$.ɵld(dirIndex)[1]) && ($instance$.someDir = $tmp$.first); + $r3$.ɵqR($tmp$ = $r3$.ɵld(dirIndex)[2]) && ($instance$.someDirList = $tmp$); }, template: function ContentQueryComponent_Template( ctx: $ContentQueryComponent$, cm: $boolean$) { @@ -1035,7 +1035,7 @@ describe('compiler specification', () => { template: function MyApp_Template(ctx: $MyApp$, cm: $boolean$) { if (cm) { $r3$.ɵE(0, ContentQueryComponent); - contentQueryComp = $r3$.ɵm(1)[0]; + contentQueryComp = $r3$.ɵld(1)[0]; $r3$.ɵE(2, 'div', $e2_attrs$, $e2_dirs$); $r3$.ɵe(); $r3$.ɵe(); @@ -1148,7 +1148,7 @@ describe('compiler specification', () => { $r3$.ɵe(); $r3$.ɵT(2); } - const l1_user = $r3$.ɵm(1); + const l1_user = $r3$.ɵld(1); $r3$.ɵt(2, $r3$.ɵi1('Hello ', l1_user.value, '!')); } }); diff --git a/packages/core/test/render3/content_spec.ts b/packages/core/test/render3/content_spec.ts index 924e27c37a..15c51d31ab 100644 --- a/packages/core/test/render3/content_spec.ts +++ b/packages/core/test/render3/content_spec.ts @@ -7,7 +7,7 @@ */ import {detectChanges} from '../../src/render3/index'; -import {componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, memory, projection, projectionDef, text} from '../../src/render3/instructions'; +import {componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, load, projection, projectionDef, text} from '../../src/render3/instructions'; import {createComponent, renderComponent, toHtml} from './render_util'; @@ -309,7 +309,7 @@ describe('content projection', () => { if (cm) { elementStart(0, Child); { - childCmptInstance = memory(1); + childCmptInstance = load(1); text(2, 'content'); } elementEnd(); @@ -362,7 +362,7 @@ describe('content projection', () => { if (cm) { elementStart(0, Child); { - childCmptInstance = memory(1); + childCmptInstance = load(1); text(2, 'content'); } elementEnd(); @@ -417,7 +417,7 @@ describe('content projection', () => { if (cm) { elementStart(0, Child); { - childCmptInstance = memory(1); + childCmptInstance = load(1); text(2, 'content'); } elementEnd(); @@ -512,7 +512,7 @@ describe('content projection', () => { if (cm) { elementStart(0, Child); { - childCmptInstance = memory(1); + childCmptInstance = load(1); text(2, 'content'); } elementEnd(); diff --git a/packages/core/test/render3/di_spec.ts b/packages/core/test/render3/di_spec.ts index b04c90b272..5e08c25542 100644 --- a/packages/core/test/render3/di_spec.ts +++ b/packages/core/test/render3/di_spec.ts @@ -11,7 +11,7 @@ import {ElementRef, TemplateRef, ViewContainerRef} from '@angular/core'; import {defineComponent} from '../../src/render3/definition'; import {InjectFlags, bloomAdd, bloomFindPossibleInjector, getOrCreateNodeInjector} from '../../src/render3/di'; import {PublicFeature, defineDirective, inject, injectElementRef, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index'; -import {bind, container, containerRefreshEnd, containerRefreshStart, createLNode, createLView, createTView, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, enterView, interpolation2, leaveView, memory, text, textBinding} from '../../src/render3/instructions'; +import {bind, container, containerRefreshEnd, containerRefreshStart, createLNode, createLView, createTView, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, enterView, interpolation2, leaveView, load, text, textBinding} from '../../src/render3/instructions'; import {LInjector} from '../../src/render3/interfaces/injector'; import {LNodeFlags} from '../../src/render3/interfaces/node'; @@ -31,7 +31,7 @@ describe('di', () => { { text(2); } elementEnd(); } - textBinding(2, bind(memory(1).value)); + textBinding(2, bind(load(1).value)); } expect(renderToHtml(Template, {})).toEqual('
Created
'); @@ -71,7 +71,7 @@ describe('di', () => { } elementEnd(); } - textBinding(5, bind(memory(4).value)); + textBinding(5, bind(load(4).value)); } expect(renderToHtml(Template, {})).toEqual('
AB
'); @@ -110,9 +110,8 @@ describe('di', () => { elementEnd(); } textBinding( - 3, - interpolation2( - '', memory(1).value, '-', memory(2).value, '')); + 3, interpolation2( + '', load(1).value, '-', load(2).value, '')); } expect(renderToHtml(Template, {})).toEqual('
ElementRef-true
'); @@ -151,9 +150,8 @@ describe('di', () => { text(3); } textBinding( - 3, - interpolation2( - '', memory(1).value, '-', memory(2).value, '')); + 3, interpolation2( + '', load(1).value, '-', load(2).value, '')); } expect(renderToHtml(Template, {})).toEqual('TemplateRef-true'); @@ -192,9 +190,8 @@ describe('di', () => { elementEnd(); } textBinding( - 3, - interpolation2( - '', memory(1).value, '-', memory(2).value, '')); + 3, interpolation2( + '', load(1).value, '-', load(2).value, '')); } expect(renderToHtml(Template, {})).toEqual('
ViewContainerRef-true
'); @@ -306,9 +303,8 @@ describe('di', () => { elementEnd(); } textBinding( - 3, - interpolation2( - '', memory(1).value, '-', memory(2).value, '')); + 3, interpolation2( + '', load(1).value, '-', load(2).value, '')); embeddedViewEnd(); } containerRefreshEnd(); diff --git a/packages/core/test/render3/directive_spec.ts b/packages/core/test/render3/directive_spec.ts index b1ae3d97dc..7c4e167b48 100644 --- a/packages/core/test/render3/directive_spec.ts +++ b/packages/core/test/render3/directive_spec.ts @@ -7,7 +7,7 @@ */ import {defineDirective} from '../../src/render3/index'; -import {bind, componentRefresh, elementEnd, elementProperty, elementStart, memory} from '../../src/render3/instructions'; +import {bind, componentRefresh, elementEnd, elementProperty, elementStart, load} from '../../src/render3/instructions'; import {renderToHtml} from './render_util'; @@ -24,8 +24,7 @@ describe('directive', () => { type: Directive, factory: () => directiveInstance = new Directive, hostBindings: (directiveIndex: number, elementIndex: number) => { - elementProperty( - elementIndex, 'className', bind(memory(directiveIndex).klass)); + elementProperty(elementIndex, 'className', bind(load(directiveIndex).klass)); } }); } diff --git a/packages/core/test/render3/exports_spec.ts b/packages/core/test/render3/exports_spec.ts index 34edd5ef18..a224965faa 100644 --- a/packages/core/test/render3/exports_spec.ts +++ b/packages/core/test/render3/exports_spec.ts @@ -7,7 +7,7 @@ */ import {defineComponent, defineDirective} from '../../src/render3/index'; -import {bind, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, memory, text, textBinding} from '../../src/render3/instructions'; +import {bind, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, load, text, textBinding} from '../../src/render3/instructions'; import {renderToHtml} from './render_util'; @@ -37,7 +37,7 @@ describe('exports', () => { elementEnd(); text(2); } - textBinding(2, memory(1).name); + textBinding(2, load(1).name); } class MyComponent { @@ -83,7 +83,7 @@ describe('exports', () => { elementStart(2, 'div', null, [MyDir]); elementEnd(); } - elementProperty(2, 'myDir', bind(memory(1))); + elementProperty(2, 'myDir', bind(load(1))); } renderToHtml(Template, {}); @@ -99,7 +99,7 @@ describe('exports', () => { elementEnd(); text(2); } - textBinding(2, memory(1).name); + textBinding(2, load(1).name); } class SomeDir { @@ -209,7 +209,7 @@ describe('exports', () => { elementStart(2, MyComponent); elementEnd(); } - elementProperty(0, 'myDir', bind(memory(3))); + elementProperty(0, 'myDir', bind(load(3))); } renderToHtml(Template, {}); @@ -229,7 +229,7 @@ describe('exports', () => { elementEnd(); } let myInput = elementStart(4); - let myComp = memory(3) as MyComponent; + let myComp = load(3); textBinding(0, bind(myInput && (myInput as any).value)); textBinding(1, bind(myComp && myComp.name)); } diff --git a/packages/core/test/render3/integration_spec.ts b/packages/core/test/render3/integration_spec.ts index c7ba705a0b..dc8ff60aaa 100644 --- a/packages/core/test/render3/integration_spec.ts +++ b/packages/core/test/render3/integration_spec.ts @@ -7,7 +7,7 @@ */ import {defineComponent, defineDirective} from '../../src/render3/index'; -import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, embeddedViewEnd, embeddedViewStart, interpolation1, interpolation2, interpolation3, interpolation4, interpolation5, interpolation6, interpolation7, interpolation8, interpolationV, memory, projection, projectionDef, text, textBinding} from '../../src/render3/instructions'; +import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, embeddedViewEnd, embeddedViewStart, interpolation1, interpolation2, interpolation3, interpolation4, interpolation5, interpolation6, interpolation7, interpolation8, interpolationV, load, projection, projectionDef, text, textBinding} from '../../src/render3/instructions'; import {containerEl, renderToHtml} from './render_util'; @@ -300,8 +300,7 @@ describe('render3 integration test', () => { hostBindings: function(directiveIndex: number, elementIndex: number): void { // host bindings elementProperty( - elementIndex, 'title', - bind(memory(directiveIndex).title)); + elementIndex, 'title', bind(load(directiveIndex).title)); } }); } diff --git a/packages/core/test/render3/lifecycle_spec.ts b/packages/core/test/render3/lifecycle_spec.ts index a104156d56..f06931b659 100644 --- a/packages/core/test/render3/lifecycle_spec.ts +++ b/packages/core/test/render3/lifecycle_spec.ts @@ -7,7 +7,7 @@ */ import {ComponentTemplate, defineComponent, defineDirective} from '../../src/render3/index'; -import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, listener, memory, projection, projectionDef, text} from '../../src/render3/instructions'; +import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, listener, projection, projectionDef, store, text} from '../../src/render3/instructions'; import {containerEl, renderToHtml} from './render_util'; diff --git a/packages/core/test/render3/properties_spec.ts b/packages/core/test/render3/properties_spec.ts index 0ecd46c55f..4d55419961 100644 --- a/packages/core/test/render3/properties_spec.ts +++ b/packages/core/test/render3/properties_spec.ts @@ -9,7 +9,7 @@ import {EventEmitter} from '@angular/core'; import {defineComponent, defineDirective} from '../../src/render3/index'; -import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, interpolation1, listener, memory, text, textBinding} from '../../src/render3/instructions'; +import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, interpolation1, listener, load, text, textBinding} from '../../src/render3/instructions'; import {renderToHtml} from './render_util'; @@ -479,7 +479,7 @@ describe('elementProperty', () => { elementEnd(); text(2); } - textBinding(2, bind(memory(1).role)); + textBinding(2, bind(load(1).role)); }, factory: () => new Comp() }); diff --git a/packages/core/test/render3/pure_function_spec.ts b/packages/core/test/render3/pure_function_spec.ts index c2c3a8c7fb..f647684fab 100644 --- a/packages/core/test/render3/pure_function_spec.ts +++ b/packages/core/test/render3/pure_function_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import {defineComponent} from '../../src/render3/index'; -import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, memory} from '../../src/render3/instructions'; +import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, load} from '../../src/render3/instructions'; import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunction5, pureFunction6, pureFunction7, pureFunction8, pureFunctionV} from '../../src/render3/pure_function'; import {renderToHtml} from '../../test/render3/render_util'; @@ -124,7 +124,7 @@ describe('array literals', () => { template: function(ctx: any, cm: boolean) { if (cm) { elementStart(0, MyComp); - myComps.push(memory(1)); + myComps.push(load(1)); elementEnd(); } elementProperty(0, 'names', bind(ctx.someFn(pureFunction1(e0_ff, ctx.customName)))); @@ -223,22 +223,22 @@ describe('array literals', () => { function Template(c: any, cm: boolean) { if (cm) { elementStart(0, MyComp); - f3Comp = memory(1); + f3Comp = load(1); elementEnd(); elementStart(2, MyComp); - f4Comp = memory(3); + f4Comp = load(3); elementEnd(); elementStart(4, MyComp); - f5Comp = memory(5); + f5Comp = load(5); elementEnd(); elementStart(6, MyComp); - f6Comp = memory(7); + f6Comp = load(7); elementEnd(); elementStart(8, MyComp); - f7Comp = memory(9); + f7Comp = load(9); elementEnd(); elementStart(10, MyComp); - f8Comp = memory(11); + f8Comp = load(11); elementEnd(); } elementProperty(0, 'names', bind(pureFunction3(e0_ff, c[5], c[6], c[7]))); @@ -444,7 +444,7 @@ describe('object literals', () => { for (let i = 0; i < 2; i++) { if (embeddedViewStart(0)) { elementStart(0, ObjectComp); - objectComps.push(memory(1)); + objectComps.push(load(1)); elementEnd(); } elementProperty( diff --git a/packages/core/test/render3/query_spec.ts b/packages/core/test/render3/query_spec.ts index d960563fed..f3cdb380e6 100644 --- a/packages/core/test/render3/query_spec.ts +++ b/packages/core/test/render3/query_spec.ts @@ -7,7 +7,7 @@ */ import {QUERY_READ_CONTAINER_REF, QUERY_READ_ELEMENT_REF, QUERY_READ_FROM_NODE, QUERY_READ_TEMPLATE_REF} from '../../src/render3/di'; import {QueryList, detectChanges} from '../../src/render3/index'; -import {container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, memory} from '../../src/render3/instructions'; +import {container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, load} from '../../src/render3/instructions'; import {query, queryRefresh} from '../../src/render3/query'; import {createComponent, createDirective, renderComponent} from './render_util'; @@ -64,15 +64,15 @@ describe('query', () => { query(1, Child, true); elementStart(2, Child); { - child1 = memory(3); + child1 = load(3); elementStart(4, Child); - { child2 = memory(5); } + { child2 = load(5); } elementEnd(); } elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query0 = tmp as QueryList); - queryRefresh(tmp = memory>(1)) && (ctx.query1 = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query0 = tmp as QueryList); + queryRefresh(tmp = load>(1)) && (ctx.query1 = tmp as QueryList); }); const parent = renderComponent(Cmp); @@ -98,7 +98,7 @@ describe('query', () => { elToQuery = elementStart(1, 'div', null, [Child]); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -124,10 +124,10 @@ describe('query', () => { if (cm) { query(0, Child, false, OtherChild); elementStart(1, 'div', null, [Child, OtherChild]); - { otherChildInstance = memory(3); } + { otherChildInstance = load(3); } elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -152,7 +152,7 @@ describe('query', () => { elementStart(1, 'div', null, [Child]); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -182,7 +182,7 @@ describe('query', () => { elementStart(2, 'div'); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -214,7 +214,7 @@ describe('query', () => { el2ToQuery = elementStart(3, 'div', null, null, ['bar', '']); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -243,7 +243,7 @@ describe('query', () => { elementStart(2, 'div'); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -267,7 +267,7 @@ describe('query', () => { elementStart(1, 'div', null, null, ['foo', '']); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -289,7 +289,7 @@ describe('query', () => { query(0, ['foo'], false, QUERY_READ_CONTAINER_REF); container(1, undefined, undefined, undefined, undefined, ['foo', '']); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -312,7 +312,7 @@ describe('query', () => { query(0, ['foo'], false, QUERY_READ_ELEMENT_REF); container(1, undefined, undefined, undefined, undefined, ['foo', '']); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -335,7 +335,7 @@ describe('query', () => { query(0, ['foo'], undefined, QUERY_READ_FROM_NODE); container(1, undefined, undefined, undefined, undefined, ['foo', '']); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -358,7 +358,7 @@ describe('query', () => { query(0, ['foo'], false, QUERY_READ_TEMPLATE_REF); container(1, undefined, undefined, undefined, undefined, ['foo', '']); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -382,10 +382,10 @@ describe('query', () => { if (cm) { query(0, ['foo'], true, QUERY_READ_FROM_NODE); elementStart(1, Child, null, null, ['foo', '']); - { childInstance = memory(2); } + { childInstance = load(2); } elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -410,10 +410,10 @@ describe('query', () => { if (cm) { query(0, ['foo'], true, QUERY_READ_FROM_NODE); elementStart(1, 'div', null, [Child], ['foo', 'child']); - childInstance = memory(2); + childInstance = load(2); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -439,12 +439,12 @@ describe('query', () => { query(0, ['foo', 'bar'], true, QUERY_READ_FROM_NODE); elementStart(1, 'div', null, [Child1, Child2], ['foo', 'child1', 'bar', 'child2']); { - child1Instance = memory(2); - child2Instance = memory(3); + child1Instance = load(2); + child2Instance = load(3); } elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -471,7 +471,7 @@ describe('query', () => { div = elementStart(1, 'div', null, [Child], ['foo', 'child']); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -495,10 +495,10 @@ describe('query', () => { if (cm) { query(0, ['foo', 'bar'], undefined, QUERY_READ_FROM_NODE); div = elementStart(1, 'div', null, [Child], ['foo', '', 'bar', 'child']); - { childInstance = memory(2); } + { childInstance = load(2); } elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -524,7 +524,7 @@ describe('query', () => { elementStart(1, 'div', null, null, ['foo', '']); elementEnd(); } - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -566,7 +566,7 @@ describe('query', () => { } } containerRefreshEnd(); - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -620,7 +620,7 @@ describe('query', () => { } } containerRefreshEnd(); - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -686,7 +686,7 @@ describe('query', () => { } } containerRefreshEnd(); - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -753,7 +753,7 @@ describe('query', () => { } } containerRefreshEnd(); - queryRefresh(tmp = memory>(0)) && (ctx.query = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); @@ -805,8 +805,8 @@ describe('query', () => { } } containerRefreshEnd(); - queryRefresh(tmp = memory>(0)) && (ctx.deep = tmp as QueryList); - queryRefresh(tmp = memory>(1)) && (ctx.shallow = tmp as QueryList); + queryRefresh(tmp = load>(0)) && (ctx.deep = tmp as QueryList); + queryRefresh(tmp = load>(1)) && (ctx.shallow = tmp as QueryList); }); const cmptInstance = renderComponent(Cmpt); diff --git a/packages/core/test/render3/view_container_ref_spec.ts b/packages/core/test/render3/view_container_ref_spec.ts index a28787ed3d..e8fa3cd087 100644 --- a/packages/core/test/render3/view_container_ref_spec.ts +++ b/packages/core/test/render3/view_container_ref_spec.ts @@ -8,7 +8,7 @@ import {TemplateRef, ViewContainerRef} from '../../src/core'; import {defineComponent, defineDirective, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index'; -import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, memory, text, textBinding} from '../../src/render3/instructions'; +import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, load, text, textBinding} from '../../src/render3/instructions'; import {renderComponent, toHtml} from './render_util'; @@ -40,7 +40,7 @@ describe('ViewContainerRef', () => { container(0, [TestDirective], subTemplate); } containerRefreshStart(0); - cmp.testDir = memory(1) as TestDirective; + cmp.testDir = load(1); TestDirective.ngDirectiveDef.h(1, 0); componentRefresh(1, 0); containerRefreshEnd();