test(compiler-cli): convert element related compliance tests (#39617)

This commit converts a set of compliance tests in the `r3_compiler_compliance_spec.ts`
file to the new testing approach.

PR Close #39617
This commit is contained in:
Pete Bacon Darwin 2020-11-11 15:29:43 +00:00 committed by atscott
parent e719419d3f
commit eea5d6b38f
32 changed files with 1106 additions and 0 deletions

View File

@ -0,0 +1,550 @@
/****************************************************************************************************
* PARTIAL FILE: svg.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 5, vars: 0, consts: [["title", "Hello", 1, "my-app"], ["cx", "20", "cy", "30", "r", "50"]], template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 0);
i0.ɵɵnamespaceSVG();
i0.ɵɵelementStart(1, "svg");
i0.ɵɵelement(2, "circle", 1);
i0.ɵɵelementEnd();
i0.ɵɵnamespaceHTML();
i0.ɵɵelementStart(3, "p");
i0.ɵɵtext(4, "test");
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: '<div class="my-app" title="Hello"><svg><circle cx="20" cy="30" r="50"/></svg><p>test</p></div>'
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: svg.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: mathml.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 5, vars: 0, consts: [["title", "Hello", 1, "my-app"]], template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 0);
i0.ɵɵnamespaceMathML();
i0.ɵɵelementStart(1, "math");
i0.ɵɵelement(2, "infinity");
i0.ɵɵelementEnd();
i0.ɵɵnamespaceHTML();
i0.ɵɵelementStart(3, "p");
i0.ɵɵtext(4, "test");
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: '<div class="my-app" title="Hello"><math><infinity/></math><p>test</p></div>'
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: mathml.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: dom.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 5, vars: 0, consts: [["title", "Hello", 1, "my-app"]], template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 0);
i0.ɵɵtext(1, "Hello ");
i0.ɵɵelementStart(2, "b");
i0.ɵɵtext(3, "World");
i0.ɵɵelementEnd();
i0.ɵɵtext(4, "!");
i0.ɵɵelementEnd();
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: '<div class="my-app" title="Hello">Hello <b>World</b>!</div>'
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: dom.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: namespace.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 5, vars: 0, consts: [[0, "xmlns", "foo", "http://someuri/foo", 0, "foo", "bar", "baz", "title", "Hello", 0, "foo", "qux", "quacks", 1, "my-app"]], template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 0);
i0.ɵɵtext(1, "Hello ");
i0.ɵɵelementStart(2, "b");
i0.ɵɵtext(3, "World");
i0.ɵɵelementEnd();
i0.ɵɵtext(4, "!");
i0.ɵɵelementEnd();
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: '<div xmlns:foo="http://someuri/foo" class="my-app" foo:bar="baz" title="Hello" foo:qux="quacks">Hello <b>World</b>!</div>'
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: namespace.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: ng-container.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 4, vars: 0, template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainerStart(0);
i0.ɵɵelementStart(1, "span");
i0.ɵɵtext(2, "in a ");
i0.ɵɵelementEnd();
i0.ɵɵtext(3, "container");
i0.ɵɵelementContainerEnd();
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: '<ng-container><span>in a </span>container</ng-container>'
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: ng-container.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: empty_ng-container.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 1, vars: 0, template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{ selector: 'my-component', template: '<ng-container></ng-container>' }]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: empty_ng-container.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: properties.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
constructor() {
this.id = 'one';
}
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 1, vars: 1, consts: [[3, "id"]], template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "div", 0);
} if (rf & 2) {
i0.ɵɵproperty("id", ctx.id);
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{ selector: 'my-component', template: '<div [id]="id"></div>' }]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: properties.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
id: string;
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: property_pure_functions.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
const _c0 = function (a0) { return [a0]; };
const _c1 = function () { return [0]; };
export class MyComponent {
constructor() {
this.id = 'one';
}
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 2, vars: 15, consts: [[3, "ternary", "pipe", "and", "or"]], template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "div", 0);
i0.ɵɵpipe(1, "pipe");
} if (rf & 2) {
i0.ɵɵproperty("ternary", ctx.cond ? i0.ɵɵpureFunction1(8, _c0, ctx.a) : i0.ɵɵpureFunction0(10, _c1))("pipe", i0.ɵɵpipeBind3(1, 4, ctx.value, 1, 2))("and", ctx.cond && i0.ɵɵpureFunction1(11, _c0, ctx.b))("or", ctx.cond || i0.ɵɵpureFunction1(13, _c0, ctx.c));
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: `<div
[ternary]="cond ? [a] : [0]"
[pipe]="value | pipe:1:2"
[and]="cond && [b]"
[or]="cond || [c]"
></div>`
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: property_pure_functions.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
id: string;
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: host_binding_pure_functions.js
****************************************************************************************************/
import { Component, Input, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
const _c0 = function (a0, a1) { return { collapsedHeight: a0, expandedHeight: a1 }; };
const _c1 = function (a0, a1) { return { value: a0, params: a1 }; };
const _c2 = function (a0, a1) { return { collapsedWidth: a0, expandedWidth: a1 }; };
export class MyComponent {
getExpandedState() {
return 'expanded';
}
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], hostVars: 14, hostBindings: function MyComponent_HostBindings(rf, ctx) { if (rf & 2) {
i0.ɵɵsyntheticHostProperty("@expansionHeight", i0.ɵɵpureFunction2(5, _c1, ctx.getExpandedState(), i0.ɵɵpureFunction2(2, _c0, ctx.collapsedHeight, ctx.expandedHeight)))("@expansionWidth", i0.ɵɵpureFunction2(11, _c1, ctx.getExpandedState(), i0.ɵɵpureFunction2(8, _c2, ctx.collapsedWidth, ctx.expandedWidth)));
} }, inputs: { expandedHeight: "expandedHeight", collapsedHeight: "collapsedHeight", expandedWidth: "expandedWidth", collapsedWidth: "collapsedWidth" }, decls: 1, vars: 0, template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵtext(0, "...");
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: '...',
host: {
'[@expansionHeight]': `{
value: getExpandedState(),
params: {
collapsedHeight: collapsedHeight,
expandedHeight: expandedHeight
}
}`,
'[@expansionWidth]': `{
value: getExpandedState(),
params: {
collapsedWidth: collapsedWidth,
expandedWidth: expandedWidth
}
}`
}
}]
}], null, { expandedHeight: [{
type: Input
}], collapsedHeight: [{
type: Input
}], expandedWidth: [{
type: Input
}], collapsedWidth: [{
type: Input
}] }); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: host_binding_pure_functions.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
expandedHeight: string;
collapsedHeight: string;
expandedWidth: string;
collapsedWidth: string;
getExpandedState(): string;
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, { "expandedHeight": "expandedHeight"; "collapsedHeight": "collapsedHeight"; "expandedWidth": "expandedWidth"; "collapsedWidth": "collapsedWidth"; }, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: class_style_bindings.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
constructor() {
this.error = true;
this.color = 'red';
}
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 1, vars: 4, template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "div");
} if (rf & 2) {
i0.ɵɵstyleProp("background-color", ctx.color);
i0.ɵɵclassProp("error", ctx.error);
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: '<div [class.error]="error" [style.background-color]="color"></div>'
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: class_style_bindings.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
error: boolean;
color: string;
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}
/****************************************************************************************************
* PARTIAL FILE: deduplicate_attributes.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import * as i0 from "@angular/core";
export class MyComponent {
}
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], decls: 2, vars: 0, consts: [["title", "hi"]], template: function MyComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "div", 0);
i0.ɵɵelement(1, "span", 0);
} }, encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyComponent, [{
type: Component,
args: [{
selector: 'my-component',
template: `
<div title="hi"></div>
<span title="hi"></span>
`
}]
}], null, null); })();
export class MyModule {
}
MyModule.ɵmod = i0.ɵɵdefineNgModule({ type: MyModule });
MyModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MyModule_Factory(t) { return new (t || MyModule)(); } });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MyModule, { declarations: [MyComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MyModule, [{
type: NgModule,
args: [{ declarations: [MyComponent] }]
}], null, null); })();
/****************************************************************************************************
* PARTIAL FILE: deduplicate_attributes.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyComponent {
static ɵfac: i0.ɵɵFactoryDef<MyComponent, never>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MyComponent, "my-component", never, {}, {}, never, never>;
}
export declare class MyModule {
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MyModule, [typeof MyComponent], never, never>;
static ɵinj: i0.ɵɵInjectorDef<MyModule>;
}

View File

@ -0,0 +1,231 @@
{
"$schema": "../test_case_schema.json",
"cases": [
{
"description": "should handle SVG",
"inputFiles": [
"svg.ts"
],
"expectations": [
{
"files": [
{
"expected": "svg_factory.js",
"generated": "svg.js"
}
],
"failureMessage": "Incorrect generated factory."
},
{
"files": [
{
"expected": "svg_template.js",
"generated": "svg.js"
}
],
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should handle MathML",
"inputFiles": [
"mathml.ts"
],
"expectations": [
{
"files": [
{
"expected": "mathml_factory.js",
"generated": "mathml.js"
}
],
"failureMessage": "Incorrect generated factory."
},
{
"files": [
{
"expected": "mathml_template.js",
"generated": "mathml.js"
}
],
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should translate DOM structure",
"inputFiles": [
"dom.ts"
],
"expectations": [
{
"files": [
{
"expected": "dom_factory.js",
"generated": "dom.js"
}
],
"failureMessage": "Incorrect generated factory."
},
{
"files": [
{
"expected": "dom_template.js",
"generated": "dom.js"
}
],
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should support namespaced attributes",
"inputFiles": [
"namespace.ts"
],
"expectations": [
{
"files": [
{
"expected": "namespace_factory.js",
"generated": "namespace.js"
}
],
"failureMessage": "Incorrect generated factory."
},
{
"files": [
{
"expected": "namespace_template.js",
"generated": "namespace.js"
}
],
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should support <ng-container>",
"inputFiles": [
"ng-container.ts"
],
"expectations": [
{
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should generate self-closing elementContainer instruction for empty <ng-container>",
"inputFiles": [
"empty_ng-container.ts"
],
"expectations": [
{
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should bind to element properties",
"inputFiles": [
"properties.ts"
],
"expectations": [
{
"files": [
{
"expected": "properties_factory.js",
"generated": "properties.js"
}
],
"failureMessage": "Incorrect generated factory."
},
{
"files": [
{
"expected": "properties_template.js",
"generated": "properties.js"
}
],
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should reserve slots for pure functions",
"inputFiles": [
"property_pure_functions.ts"
],
"expectations": [
{
"files": [
{
"expected": "property_pure_functions_factory.js",
"generated": "property_pure_functions.js"
}
],
"failureMessage": "Incorrect generated factory."
},
{
"files": [
{
"expected": "property_pure_functions_template.js",
"generated": "property_pure_functions.js"
}
],
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should reserve slots for pure functions in host binding function",
"inputFiles": [
"host_binding_pure_functions.ts"
],
"expectations": [
{
"failureMessage": "Incorrect `hostBindings` function."
}
]
},
{
"description": "should bind to class and style names",
"inputFiles": [
"class_style_bindings.ts"
],
"expectations": [
{
"files": [
{
"expected": "class_style_bindings_factory.js",
"generated": "class_style_bindings.js"
}
],
"failureMessage": "Incorrect generated factory."
},
{
"files": [
{
"expected": "class_style_bindings_template.js",
"generated": "class_style_bindings.js"
}
],
"failureMessage": "Incorrect generated template."
}
]
},
{
"description": "should de-duplicate attribute arrays",
"inputFiles": [
"deduplicate_attributes.ts"
],
"expectations": [
{
"failureMessage": "Incorrect generated template."
}
]
}
]
}

View File

@ -0,0 +1,14 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template: '<div [class.error]="error" [style.background-color]="color"></div>'
})
export class MyComponent {
error = true;
color = 'red';
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1 @@
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }

View File

@ -0,0 +1,14 @@
MyComponent.ɵcmp = i0.ɵɵdefineComponent({type:MyComponent,selectors:[["my-component"]],
decls: 1,
vars: 4,
template: function MyComponent_Template(rf,ctx){
if (rf & 1) {
$r3$.ɵɵelement(0, "div");
}
if (rf & 2) {
$r3$.ɵɵstyleProp("background-color", ctx.color);
$r3$.ɵɵclassProp("error", ctx.error);
}
},
encapsulation: 2
});

View File

@ -0,0 +1,8 @@
consts: [["title", "hi"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelement(0, "div", 0);
$r3$.ɵɵelement(1, "span", 0);
}
}

View File

@ -0,0 +1,15 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template: `
<div title="hi"></div>
<span title="hi"></span>
`
})
export class MyComponent {
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1,12 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template: '<div class="my-app" title="Hello">Hello <b>World</b>!</div>'
})
export class MyComponent {
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1 @@
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }

View File

@ -0,0 +1,13 @@
// NOTE: AttributeMarker.Classes = 1
consts: [["title", "Hello", 1, "my-app"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
$r3$.ɵɵtext(1, "Hello ");
$r3$.ɵɵelementStart(2, "b");
$r3$.ɵɵtext(3, "World");
$r3$.ɵɵelementEnd();
$r3$.ɵɵtext(4, "!");
$r3$.ɵɵelementEnd();
}
}

View File

@ -0,0 +1,6 @@
// NOTE: The template should look like this (where IDENT is a wild card for an identifier):
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
i0.ɵɵelementContainer(0);
}
}

View File

@ -0,0 +1,9 @@
import {Component, NgModule} from '@angular/core';
@Component({selector: 'my-component', template: '<ng-container></ng-container>'})
export class MyComponent {
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1,18 @@
const $_c0$ = function (a0, a1) { return { collapsedHeight: a0, expandedHeight: a1 }; };
const $_c1$ = function (a0, a1) { return { value: a0, params: a1 }; };
const $_c2$ = function (a0, a1) { return { collapsedWidth: a0, expandedWidth: a1 }; };
hostVars: 14,
hostBindings: function MyComponent_HostBindings(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵsyntheticHostProperty("@expansionHeight",
$r3$.ɵɵpureFunction2(5, $_c1$, ctx.getExpandedState(),
$r3$.ɵɵpureFunction2(2, $_c0$, ctx.collapsedHeight, ctx.expandedHeight)
)
)("@expansionWidth",
$r3$.ɵɵpureFunction2(11, $_c1$, ctx.getExpandedState(),
$r3$.ɵɵpureFunction2(8, $_c2$, ctx.collapsedWidth, ctx.expandedWidth)
)
);
}
},

View File

@ -0,0 +1,37 @@
import {Component, Input, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template: '...',
host: {
'[@expansionHeight]': `{
value: getExpandedState(),
params: {
collapsedHeight: collapsedHeight,
expandedHeight: expandedHeight
}
}`,
'[@expansionWidth]': `{
value: getExpandedState(),
params: {
collapsedWidth: collapsedWidth,
expandedWidth: expandedWidth
}
}`
}
})
export class MyComponent {
@Input() expandedHeight!: string;
@Input() collapsedHeight!: string;
@Input() expandedWidth!: string;
@Input() collapsedWidth!: string;
getExpandedState() {
return 'expanded';
}
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1,15 @@
consts: [["title", "Hello", ${AttributeMarker.Classes}, "my-app"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
$r3$.ɵɵnamespaceMathML();
$r3$.ɵɵelementStart(1, "math");
$r3$.ɵɵelement(2, "infinity");
$r3$.ɵɵelementEnd();
$r3$.ɵɵnamespaceHTML();
$r3$.ɵɵelementStart(3, "p");
$r3$.ɵɵtext(4, "test");
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementEnd();
}
}

View File

@ -0,0 +1,12 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template: '<div class="my-app" title="Hello"><math><infinity/></math><p>test</p></div>'
})
export class MyComponent {
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1 @@
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }

View File

@ -0,0 +1,16 @@
// NOTE: AttributeMarker.Classes = 1
consts: [["title", "Hello", 1, "my-app"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
$r3$.ɵɵnamespaceMathML();
$r3$.ɵɵelementStart(1, "math");
$r3$.ɵɵelement(2, "infinity");
$r3$.ɵɵelementEnd();
$r3$.ɵɵnamespaceHTML();
$r3$.ɵɵelementStart(3, "p");
$r3$.ɵɵtext(4, "test");
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementEnd();
}
}

View File

@ -0,0 +1,13 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template:
'<div xmlns:foo="http://someuri/foo" class="my-app" foo:bar="baz" title="Hello" foo:qux="quacks">Hello <b>World</b>!</div>'
})
export class MyComponent {
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1 @@
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }

View File

@ -0,0 +1,19 @@
// NOTE: AttributeMarker.NamespaceURI = 0
// NOTE: AttributeMarker.Classes = 1
consts: [[
0, "xmlns", "foo", "http://someuri/foo",
0, "foo", "bar", "baz",
"title", "Hello",
0, "foo", "qux", "quacks",
1, "my-app"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
$r3$.ɵɵtext(1, "Hello ");
$r3$.ɵɵelementStart(2, "b");
$r3$.ɵɵtext(3, "World");
$r3$.ɵɵelementEnd();
$r3$.ɵɵtext(4, "!");
$r3$.ɵɵelementEnd();
}
}

View File

@ -0,0 +1,10 @@
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
i0.ɵɵelementContainerStart(0);
i0.ɵɵelementStart(1, "span");
i0.ɵɵtext(2, "in a ");
i0.ɵɵelementEnd();
i0.ɵɵtext(3, "container");
i0.ɵɵelementContainerEnd();
}
}

View File

@ -0,0 +1,12 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template: '<ng-container><span>in a </span>container</ng-container>'
})
export class MyComponent {
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1,10 @@
import {Component, NgModule} from '@angular/core';
@Component({selector: 'my-component', template: '<div [id]="id"></div>'})
export class MyComponent {
id = 'one';
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1 @@
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }

View File

@ -0,0 +1,10 @@
// NOTE: AttributeMarker.Bindings = 3
consts: [[3, "id"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelement(0, "div", 0);
}
if (rf & 2) {
$r3$.ɵɵproperty("id", ctx.id);
}
}

View File

@ -0,0 +1,18 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template: `<div
[ternary]="cond ? [a] : [0]"
[pipe]="value | pipe:1:2"
[and]="cond && [b]"
[or]="cond || [c]"
></div>`
})
export class MyComponent {
id = 'one';
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1 @@
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }

View File

@ -0,0 +1,9 @@
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelement(0, "div", 0);
$r3$.ɵɵpipe(1, "pipe");
}
if (rf & 2) {
$r3$.ɵɵproperty("ternary", ctx.cond ? $r3$.ɵɵpureFunction1(8, $c0$, ctx.a): $r3$.ɵɵpureFunction0(10, $c1$))("pipe", $r3$.ɵɵpipeBind3(1, 4, ctx.value, 1, 2))("and", ctx.cond && $r3$.ɵɵpureFunction1(11, $c0$, ctx.b))("or", ctx.cond || $r3$.ɵɵpureFunction1(13, $c0$, ctx.c));
}
}

View File

@ -0,0 +1,13 @@
import {Component, NgModule} from '@angular/core';
@Component({
selector: 'my-component',
template:
'<div class="my-app" title="Hello"><svg><circle cx="20" cy="30" r="50"/></svg><p>test</p></div>'
})
export class MyComponent {
}
@NgModule({declarations: [MyComponent]})
export class MyModule {
}

View File

@ -0,0 +1 @@
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }

View File

@ -0,0 +1,15 @@
consts: [["title", "Hello", 1, "my-app"], ["cx", "20", "cy", "30", "r", "50"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
$r3$.ɵɵnamespaceSVG();
$r3$.ɵɵelementStart(1, "svg");
$r3$.ɵɵelement(2, "circle", 1);
$r3$.ɵɵelementEnd();
$r3$.ɵɵnamespaceHTML();
$r3$.ɵɵelementStart(3, "p");
$r3$.ɵɵtext(4, "test");
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementEnd();
}
}