refactor(ivy): use `element()` where applicable in di_spec (#25166)
For future ref Search `elementStart\(([^)]+)\);\s*\n\s*elementEnd\(\);` Replace `element($1)` PR Close #25166
This commit is contained in:
parent
9ea112473b
commit
7f59170f77
|
@ -12,7 +12,7 @@ import {RenderFlags} from '@angular/core/src/render3/interfaces/definition';
|
||||||
import {defineComponent} from '../../src/render3/definition';
|
import {defineComponent} from '../../src/render3/definition';
|
||||||
import {bloomAdd, bloomFindPossibleInjector, getOrCreateNodeInjector, injectAttribute} from '../../src/render3/di';
|
import {bloomAdd, bloomFindPossibleInjector, getOrCreateNodeInjector, injectAttribute} from '../../src/render3/di';
|
||||||
import {NgOnChangesFeature, PublicFeature, defineDirective, directiveInject, injectChangeDetectorRef, injectElementRef, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
|
import {NgOnChangesFeature, PublicFeature, defineDirective, directiveInject, injectChangeDetectorRef, injectElementRef, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
|
||||||
import {bind, container, containerRefreshEnd, containerRefreshStart, createLNode, createLViewData, createTView, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, enterView, interpolation2, leaveView, load, projection, projectionDef, text, textBinding} from '../../src/render3/instructions';
|
import {bind, container, containerRefreshEnd, containerRefreshStart, createLNode, createLViewData, createTView, element, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, enterView, interpolation2, leaveView, load, projection, projectionDef, text, textBinding} from '../../src/render3/instructions';
|
||||||
import {LInjector} from '../../src/render3/interfaces/injector';
|
import {LInjector} from '../../src/render3/interfaces/injector';
|
||||||
import {AttributeMarker, TNodeType} from '../../src/render3/interfaces/node';
|
import {AttributeMarker, TNodeType} from '../../src/render3/interfaces/node';
|
||||||
import {LViewFlags} from '../../src/render3/interfaces/view';
|
import {LViewFlags} from '../../src/render3/interfaces/view';
|
||||||
|
@ -131,8 +131,7 @@ describe('di', () => {
|
||||||
/** <div dirA dirB></div> */
|
/** <div dirA dirB></div> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '', 'dirB', '']);
|
element(0, 'div', ['dirA', '', 'dirB', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
|
@ -157,10 +156,8 @@ describe('di', () => {
|
||||||
// - if not found, it will check the module injector tree
|
// - if not found, it will check the module injector tree
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirB', '']);
|
element(0, 'div', ['dirB', '']);
|
||||||
elementEnd();
|
element(1, 'div', ['dirA', '']);
|
||||||
elementStart(1, 'div', ['dirA', '']);
|
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
|
@ -190,8 +187,7 @@ describe('di', () => {
|
||||||
/** <comp dirB></comp> */
|
/** <comp dirB></comp> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'comp', ['dirB', '']);
|
element(0, 'comp', ['dirB', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Comp, DirB]);
|
}, [Comp, DirB]);
|
||||||
|
|
||||||
|
@ -223,8 +219,7 @@ describe('di', () => {
|
||||||
{
|
{
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
if (embeddedViewStart(0)) {
|
if (embeddedViewStart(0)) {
|
||||||
elementStart(0, 'div', ['dirA', '', 'dirB', '']);
|
element(0, 'div', ['dirA', '', 'dirB', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
embeddedViewEnd();
|
embeddedViewEnd();
|
||||||
}
|
}
|
||||||
|
@ -277,8 +272,7 @@ describe('di', () => {
|
||||||
/** <div dirA dirB dirC></div> */
|
/** <div dirA dirB dirC></div> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '', 'dirB', '', 'dirC', '']);
|
element(0, 'div', ['dirA', '', 'dirB', '', 'dirC', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB, DirC]);
|
}, [DirA, DirB, DirC]);
|
||||||
|
|
||||||
|
@ -337,8 +331,7 @@ describe('di', () => {
|
||||||
/** <comp dirA dirB dirC dirD></comp> */
|
/** <comp dirA dirB dirC dirD></comp> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'comp', ['dirA', '', 'dirB', '', 'dirC', '', 'dirD', '']);
|
element(0, 'comp', ['dirA', '', 'dirB', '', 'dirC', '', 'dirD', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Comp, DirA, DirB, DirC, DirD]);
|
}, [Comp, DirA, DirB, DirC, DirD]);
|
||||||
|
|
||||||
|
@ -370,8 +363,7 @@ describe('di', () => {
|
||||||
/** <div dirA dirB dirC></div> */
|
/** <div dirA dirB dirC></div> */
|
||||||
template: (rf: RenderFlags, ctx: any) => {
|
template: (rf: RenderFlags, ctx: any) => {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '', 'dirB', '', 'dirC', 'dirC']);
|
element(0, 'div', ['dirA', '', 'dirB', '', 'dirC', 'dirC']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
directives: [DirA, DirB],
|
directives: [DirA, DirB],
|
||||||
|
@ -415,16 +407,14 @@ describe('di', () => {
|
||||||
/** <div dirA dirB></div> */
|
/** <div dirA dirB></div> */
|
||||||
const Parent = createComponent('parent', function(rf: RenderFlags, ctx: any) {
|
const Parent = createComponent('parent', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '', 'dirB', '']);
|
element(0, 'div', ['dirA', '', 'dirB', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
/** <parent dirB></parent> */
|
/** <parent dirB></parent> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'parent', ['dirB', '']);
|
element(0, 'parent', ['dirB', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Parent, DirB]);
|
}, [Parent, DirB]);
|
||||||
|
|
||||||
|
@ -485,8 +475,7 @@ describe('di', () => {
|
||||||
/** <div dir></div> */
|
/** <div dir></div> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dir', '']);
|
element(0, 'div', ['dir', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Dir, OtherDir]);
|
}, [Dir, OtherDir]);
|
||||||
|
|
||||||
|
@ -520,10 +509,8 @@ describe('di', () => {
|
||||||
*/
|
*/
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['other', '']);
|
element(0, 'div', ['other', '']);
|
||||||
elementEnd();
|
element(1, 'div', ['dir', '']);
|
||||||
elementStart(1, 'div', ['dir', '']);
|
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Dir, OtherDir]);
|
}, [Dir, OtherDir]);
|
||||||
|
|
||||||
|
@ -557,8 +544,7 @@ describe('di', () => {
|
||||||
/** <div dirA dirB></div> */
|
/** <div dirA dirB></div> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '', 'dirB', '']);
|
element(0, 'div', ['dirA', '', 'dirB', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
|
@ -580,8 +566,7 @@ describe('di', () => {
|
||||||
/** <div dir></div> */
|
/** <div dir></div> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dir', '']);
|
element(0, 'div', ['dir', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Dir]);
|
}, [Dir]);
|
||||||
|
|
||||||
|
@ -619,8 +604,7 @@ describe('di', () => {
|
||||||
/** <div dirA></div> */
|
/** <div dirA></div> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '']);
|
element(0, 'div', ['dirA', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
|
@ -649,10 +633,8 @@ describe('di', () => {
|
||||||
*/
|
*/
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirB', '']);
|
element(0, 'div', ['dirB', '']);
|
||||||
elementEnd();
|
element(1, 'div', ['dirA', '']);
|
||||||
elementStart(1, 'div', ['dirA', '']);
|
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
|
@ -678,16 +660,14 @@ describe('di', () => {
|
||||||
/** <div dirA dirB="self"></div> */
|
/** <div dirA dirB="self"></div> */
|
||||||
const Comp = createComponent('comp', function(rf: RenderFlags, ctx: any) {
|
const Comp = createComponent('comp', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '', 'dirB', 'self']);
|
element(0, 'div', ['dirA', '', 'dirB', 'self']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
/* <comp dirB="parent"></comp> */
|
/* <comp dirB="parent"></comp> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'comp', ['dirB', 'parent']);
|
element(0, 'comp', ['dirB', 'parent']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Comp, DirB]);
|
}, [Comp, DirB]);
|
||||||
|
|
||||||
|
@ -716,8 +696,7 @@ describe('di', () => {
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirB', '']);
|
elementStart(0, 'div', ['dirB', '']);
|
||||||
elementStart(1, 'div', ['dirA', '']);
|
element(1, 'div', ['dirA', '']);
|
||||||
elementEnd();
|
|
||||||
elementEnd();
|
elementEnd();
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
@ -748,8 +727,7 @@ describe('di', () => {
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirB', '']);
|
elementStart(0, 'div', ['dirB', '']);
|
||||||
elementStart(1, 'div', ['dirA', '', 'dirC', '']);
|
element(1, 'div', ['dirA', '', 'dirC', '']);
|
||||||
elementEnd();
|
|
||||||
elementEnd();
|
elementEnd();
|
||||||
}
|
}
|
||||||
}, [DirA, DirB, DirC]);
|
}, [DirA, DirB, DirC]);
|
||||||
|
@ -777,16 +755,14 @@ describe('di', () => {
|
||||||
/** <div dirA></div> */
|
/** <div dirA></div> */
|
||||||
const Comp = createComponent('comp', function(rf: RenderFlags, ctx: any) {
|
const Comp = createComponent('comp', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'div', ['dirA', '']);
|
element(0, 'div', ['dirA', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [DirA, DirB]);
|
}, [DirA, DirB]);
|
||||||
|
|
||||||
/* <comp dirB></comp> */
|
/* <comp dirB></comp> */
|
||||||
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'comp', ['dirB', '']);
|
element(0, 'comp', ['dirB', '']);
|
||||||
elementEnd();
|
|
||||||
}
|
}
|
||||||
}, [Comp, DirB]);
|
}, [Comp, DirB]);
|
||||||
|
|
||||||
|
@ -1037,8 +1013,7 @@ describe('di', () => {
|
||||||
/** <my-comp dir dirSameInstance #dir="dir"></my-comp> {{ dir.value }} */
|
/** <my-comp dir dirSameInstance #dir="dir"></my-comp> {{ dir.value }} */
|
||||||
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
|
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'my-comp', ['dir', '', 'dirSame', ''], ['dir', 'dir']);
|
element(0, 'my-comp', ['dir', '', 'dirSame', ''], ['dir', 'dir']);
|
||||||
elementEnd();
|
|
||||||
text(2);
|
text(2);
|
||||||
}
|
}
|
||||||
let tmp: any;
|
let tmp: any;
|
||||||
|
@ -1108,10 +1083,7 @@ describe('di', () => {
|
||||||
template: function(rf: RenderFlags, ctx: any) {
|
template: function(rf: RenderFlags, ctx: any) {
|
||||||
if (rf & RenderFlags.Create) {
|
if (rf & RenderFlags.Create) {
|
||||||
elementStart(0, 'my-comp');
|
elementStart(0, 'my-comp');
|
||||||
{
|
{ element(1, 'div', ['dir', '', 'dirSame', ''], ['dir', 'dir']); }
|
||||||
elementStart(1, 'div', ['dir', '', 'dirSame', ''], ['dir', 'dir']);
|
|
||||||
elementEnd();
|
|
||||||
}
|
|
||||||
elementEnd();
|
elementEnd();
|
||||||
text(3);
|
text(3);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue