fix(ivy): match directives on bindings and element outputs (#25614)
Closes #23560 PR Close #25614
This commit is contained in:

committed by
Matias Niemelä

parent
3634575d89
commit
6a0f78fabf
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {InitialStylingFlags} from '@angular/compiler/src/core';
|
||||
import {AttributeMarker, InitialStylingFlags} from '@angular/compiler/src/core';
|
||||
import {setup} from '@angular/compiler/test/aot/test_util';
|
||||
import {compile, expectEmit} from './mock_compile';
|
||||
|
||||
@ -200,7 +200,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// The template should look like this (where IDENT is a wild card for an identifier):
|
||||
const template = `
|
||||
const $c1$ = ["class", "my-app", 0, "http://someuri/foo", "foo:bar", "baz", "title", "Hello", 0, "http://someuri/foo", "foo:qux", "quacks"];
|
||||
const $e0_attrs$ = ["class", "my-app", 0, "http://someuri/foo", "foo:bar", "baz", "title", "Hello", 0, "http://someuri/foo", "foo:qux", "quacks"];
|
||||
…
|
||||
template: function MyComponent_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
@ -315,9 +315,11 @@ describe('compiler compliance', () => {
|
||||
const factory =
|
||||
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
const template = `
|
||||
const $e0_attrs$ = [${AttributeMarker.SelectOnly}, "id"];
|
||||
…
|
||||
template: function MyComponent_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelement(0, "div");
|
||||
$r3$.ɵelement(0, "div", $e0_attrs$);
|
||||
}
|
||||
if (rf & 2) {
|
||||
$r3$.ɵelementProperty(0, "id", $r3$.ɵbind(ctx.id));
|
||||
@ -357,19 +359,20 @@ describe('compiler compliance', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const $e0_attrs$ = [];
|
||||
const factory =
|
||||
'factory: function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
const template = `
|
||||
template: function MyComponent_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelement(0, "div");
|
||||
$r3$.ɵelement(0, "div", $e0_attrs$);
|
||||
$r3$.ɵpipe(1,"pipe");
|
||||
}
|
||||
if (rf & 2) {
|
||||
$r3$.ɵelementProperty(0, "ternary", $r3$.ɵbind((ctx.cond ? $r3$.ɵpureFunction1(8, _c0, ctx.a): _c1)));
|
||||
$r3$.ɵelementProperty(0, "ternary", $r3$.ɵbind((ctx.cond ? $r3$.ɵpureFunction1(8, $c0$, ctx.a): $c1$)));
|
||||
$r3$.ɵelementProperty(0, "pipe", $r3$.ɵbind($r3$.ɵpipeBind3(1, 4, ctx.value, 1, 2)));
|
||||
$r3$.ɵelementProperty(0, "and", $r3$.ɵbind((ctx.cond && $r3$.ɵpureFunction1(10, _c0, ctx.b))));
|
||||
$r3$.ɵelementProperty(0, "or", $r3$.ɵbind((ctx.cond || $r3$.ɵpureFunction1(12, _c0, ctx.c))));
|
||||
$r3$.ɵelementProperty(0, "and", $r3$.ɵbind((ctx.cond && $r3$.ɵpureFunction1(10, $c0$, ctx.b))));
|
||||
$r3$.ɵelementProperty(0, "or", $r3$.ɵbind((ctx.cond || $r3$.ɵpureFunction1(12, $c0$, ctx.c))));
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -705,6 +708,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const MyAppDeclaration = `
|
||||
const $e0_attrs$ = [${AttributeMarker.SelectOnly}, "names"];
|
||||
const $e0_ff$ = function ($v$) { return ["Nancy", $v$]; };
|
||||
…
|
||||
MyApp.ngComponentDef = $r3$.ɵdefineComponent({
|
||||
@ -716,7 +720,7 @@ describe('compiler compliance', () => {
|
||||
vars: 3,
|
||||
template: function MyApp_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelement(0, "my-comp");
|
||||
$r3$.ɵelement(0, "my-comp", $e0_attrs$);
|
||||
}
|
||||
if (rf & 2) {
|
||||
$r3$.ɵelementProperty(0, "names", $r3$.ɵbind($r3$.ɵpureFunction1(1, $e0_ff$, ctx.customName)));
|
||||
@ -784,6 +788,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const MyAppDefinition = `
|
||||
const $e0_attr$ = [${AttributeMarker.SelectOnly}, "names"];
|
||||
const $e0_ff$ = function ($v0$, $v1$, $v2$, $v3$, $v4$, $v5$, $v6$, $v7$, $v8$) {
|
||||
return ["start-", $v0$, $v1$, $v2$, $v3$, $v4$, "-middle-", $v5$, $v6$, $v7$, $v8$, "-end"];
|
||||
}
|
||||
@ -797,7 +802,7 @@ describe('compiler compliance', () => {
|
||||
vars: 11,
|
||||
template: function MyApp_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelement(0, "my-comp");
|
||||
$r3$.ɵelement(0, "my-comp", $e0_attr$);
|
||||
}
|
||||
if (rf & 2) {
|
||||
$r3$.ɵelementProperty(
|
||||
@ -849,6 +854,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const MyAppDefinition = `
|
||||
const $e0_attrs$ = [${AttributeMarker.SelectOnly}, "config"];
|
||||
const $e0_ff$ = function ($v$) { return {"duration": 500, animation: $v$}; };
|
||||
…
|
||||
MyApp.ngComponentDef = $r3$.ɵdefineComponent({
|
||||
@ -860,7 +866,7 @@ describe('compiler compliance', () => {
|
||||
vars: 3,
|
||||
template: function MyApp_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelement(0, "object-comp");
|
||||
$r3$.ɵelement(0, "object-comp", $e0_attrs$);
|
||||
}
|
||||
if (rf & 2) {
|
||||
$r3$.ɵelementProperty(0, "config", $r3$.ɵbind($r3$.ɵpureFunction1(1, $e0_ff$, ctx.name)));
|
||||
@ -913,6 +919,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const MyAppDefinition = `
|
||||
const $e0_attrs$ = [${AttributeMarker.SelectOnly}, "config"];
|
||||
const $c0$ = {opacity: 0, duration: 0};
|
||||
const $e0_ff$ = function ($v$) { return {opacity: 1, duration: $v$}; };
|
||||
const $e0_ff_1$ = function ($v$) { return [$c0$, $v$]; };
|
||||
@ -927,7 +934,7 @@ describe('compiler compliance', () => {
|
||||
vars: 8,
|
||||
template: function MyApp_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelement(0, "nested-comp");
|
||||
$r3$.ɵelement(0, "nested-comp", $e0_attrs$);
|
||||
}
|
||||
if (rf & 2) {
|
||||
$r3$.ɵelementProperty(
|
||||
@ -1433,9 +1440,9 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const template = `
|
||||
const $c0$ = ["ngFor","","ngForOf",""];
|
||||
const $c0$ = ["ngFor", "" , ${AttributeMarker.SelectOnly}, "ngForOf"];
|
||||
const $c1$ = ["foo", ""];
|
||||
const $c2$ = ["ngIf",""];
|
||||
const $c2$ = [${AttributeMarker.SelectOnly}, "ngIf"];
|
||||
|
||||
function MyComponent_div_span_Template_3(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
@ -1545,8 +1552,8 @@ describe('compiler compliance', () => {
|
||||
vars: 2,
|
||||
template: function SimpleLayout_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelement(0, "lifecycle-comp");
|
||||
$r3$.ɵelement(1, "lifecycle-comp");
|
||||
$r3$.ɵelement(0, "lifecycle-comp", $e0_attrs$);
|
||||
$r3$.ɵelement(1, "lifecycle-comp", $e1_attrs$);
|
||||
}
|
||||
if (rf & 2) {
|
||||
$r3$.ɵelementProperty(0, "name", $r3$.ɵbind(ctx.name1));
|
||||
@ -1656,7 +1663,7 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const MyComponentDefinition = `
|
||||
const $_c0$ = ["for","","forOf",""];
|
||||
const $t1_attrs$ = ["for", "", ${AttributeMarker.SelectOnly}, "forOf"];
|
||||
function MyComponent__svg_g_Template_1(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵnamespaceSVG();
|
||||
@ -1677,7 +1684,7 @@ describe('compiler compliance', () => {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵnamespaceSVG();
|
||||
$r3$.ɵelementStart(0,"svg");
|
||||
$r3$.ɵtemplate(1, MyComponent__svg_g_Template_1, 2, 0, null, $_c0$);
|
||||
$r3$.ɵtemplate(1, MyComponent__svg_g_Template_1, 2, 0, null, $t1_attrs$);
|
||||
$r3$.ɵelementEnd();
|
||||
}
|
||||
if (rf & 2) { $r3$.ɵelementProperty(1,"forOf",$r3$.ɵbind(ctx.items)); }
|
||||
@ -1732,7 +1739,7 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const MyComponentDefinition = `
|
||||
const $_c0$ = ["for","","forOf",""];
|
||||
const $t1_attrs$ = ["for", "", ${AttributeMarker.SelectOnly}, "forOf"];
|
||||
function MyComponent_li_Template_1(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelementStart(0, "li");
|
||||
@ -1755,7 +1762,7 @@ describe('compiler compliance', () => {
|
||||
template: function MyComponent_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelementStart(0, "ul");
|
||||
$r3$.ɵtemplate(1, MyComponent_li_Template_1, 2, 1, null, $_c0$);
|
||||
$r3$.ɵtemplate(1, MyComponent_li_Template_1, 2, 1, null, $t1_attrs$);
|
||||
$r3$.ɵelementEnd();
|
||||
}
|
||||
if (rf & 2) {
|
||||
@ -1812,7 +1819,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const MyComponentDefinition = `
|
||||
const $c1$ = ["for", "", "forOf", ""];
|
||||
const $t4_attrs$ = ["for", "", ${AttributeMarker.SelectOnly}, "forOf"];
|
||||
function MyComponent_li_li_Template_4(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
$r3$.ɵelementStart(0, "li");
|
||||
@ -1833,7 +1840,7 @@ describe('compiler compliance', () => {
|
||||
$r3$.ɵtext(2);
|
||||
$r3$.ɵelementEnd();
|
||||
$r3$.ɵelementStart(3, "ul");
|
||||
$r3$.ɵtemplate(4, MyComponent_li_li_Template_4, 2, 2, null, $c1$);
|
||||
$r3$.ɵtemplate(4, MyComponent_li_li_Template_4, 2, 2, null, $t4_attrs$);
|
||||
$r3$.ɵelementEnd();
|
||||
$r3$.ɵelementEnd();
|
||||
}
|
||||
|
Reference in New Issue
Block a user