*/
- const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
- if (rf & RenderFlags.Create) {
- ɵɵelement(0, 'div');
- ɵɵelement(1, 'input', ['value', 'one'], ['myInput', '']);
- }
- if (rf & RenderFlags.Update) {
- const tmp = ɵɵreference(2) as any;
- ɵɵelementAttribute(0, 'aria-label', ɵɵbind(tmp.value));
- }
- }, 3, 1);
-
- const fixture = new ComponentFixture(App);
- expect(fixture.html).toEqual('
*/
- const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
- if (rf & RenderFlags.Create) {
- ɵɵelementStart(0, 'div', [AttributeMarker.Classes, 'red']);
- ɵɵelementStyling(['red']);
- ɵɵelementEnd();
- ɵɵelement(1, 'input', ['type', 'checkbox', 'checked', 'true'], ['myInput', '']);
- }
- if (rf & RenderFlags.Update) {
- const tmp = ɵɵreference(2) as any;
- ɵɵelementClassProp(0, 0, tmp.checked);
- ɵɵelementStylingApply(0);
- }
- }, 3);
-
- const fixture = new ComponentFixture(App);
- expect(fixture.html).toEqual('
');
- });
-
- it('should work with component refs', () => {
-
- let myComponent: MyComponent;
- let myDir: MyDir;
-
- class MyComponent {
- constructor() { myComponent = this; }
-
- static ngComponentDef = ɵɵdefineComponent({
- type: MyComponent,
- selectors: [['comp']],
- consts: 0,
- vars: 0,
- template: function(rf: RenderFlags, ctx: MyComponent) {},
- factory: () => new MyComponent
- });
- }
-
- class MyDir {
- // TODO(issue/24571): remove '!'.
- myDir !: MyComponent;
-
- constructor() { myDir = this; }
-
- static ngDirectiveDef = ɵɵdefineDirective({
- type: MyDir,
- selectors: [['', 'myDir', '']],
- factory: () => new MyDir,
- inputs: {myDir: 'myDir'}
- });
- }
-
- /**
*/
- const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
- if (rf & RenderFlags.Create) {
- ɵɵelement(0, 'div', ['myDir', '']);
- ɵɵelement(1, 'comp', null, ['myComp', '']);
- }
- if (rf & RenderFlags.Update) {
- const tmp = ɵɵreference(2) as any;
- ɵɵelementProperty(0, 'myDir', ɵɵbind(tmp));
- }
- }, 3, 1, [MyComponent, MyDir]);
-
- const fixture = new ComponentFixture(App);
- expect(myDir !.myDir).toEqual(myComponent !);
- });
-
- it('should work with multiple forward refs', () => {
- let myComponent: MyComponent;
-
- class MyComponent {
- name = 'Nancy';
-
- constructor() { myComponent = this; }
-
- static ngComponentDef = ɵɵdefineComponent({
- type: MyComponent,
- selectors: [['comp']],
- consts: 0,
- vars: 0,
- template: function() {},
- factory: () => new MyComponent
- });
- }
-
- /** {{ myInput.value }} {{ myComp.name }}
- */
- const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
- if (rf & RenderFlags.Create) {
- ɵɵtext(0);
- ɵɵtext(1);
- ɵɵelement(2, 'comp', null, ['myComp', '']);
- ɵɵelement(4, 'input', ['value', 'one'], ['myInput', '']);
- }
- if (rf & RenderFlags.Update) {
- const tmp1 = ɵɵreference(3) as any;
- const tmp2 = ɵɵreference(5) as any;
- ɵɵtextBinding(0, ɵɵbind(tmp2.value));
- ɵɵtextBinding(1, ɵɵbind(tmp1.name));
- }
- }, 6, 2, [MyComponent]);
-
- const fixture = new ComponentFixture(App);
- expect(fixture.html).toEqual('oneNancy
');
- });
+ /**
+ * This test needs to be moved to acceptance/exports_spec.ts
+ * when Ivy compiler supports inline views.
+ */
it('should work inside a view container', () => {
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) {
@@ -214,74 +58,5 @@ describe('exports', () => {
fixture.update();
expect(fixture.html).toEqual('
');
});
-
- it('should support local refs in nested dynamic views', () => {
- /**
- *
- *
- * {{ outerInput.value }}
- *
- *
- *
- *
- * {{ outerInput.value }} - {{ innerInput.value}}
- *
- *
- */
- const App = createComponent('app', function(rf: RenderFlags, app: any) {
- if (rf & RenderFlags.Create) {
- ɵɵelementStart(0, 'input', ['value', 'one'], ['outerInput', '']);
- ɵɵelementEnd();
- ɵɵtemplate(2, outerTemplate, 5, 2, 'div', [AttributeMarker.Template, 'ngIf']);
- }
- if (rf & RenderFlags.Update) {
- ɵɵelementProperty(2, 'ngIf', ɵɵbind(app.outer));
- }
- }, 3, 1, [NgIf]);
-
- function outerTemplate(rf: RenderFlags, outer: any) {
- if (rf & RenderFlags.Create) {
- ɵɵelementStart(0, 'div');
- {
- ɵɵtext(1);
- ɵɵelementStart(2, 'input', ['value', 'two'], ['innerInput', '']);
- ɵɵelementEnd();
- ɵɵtemplate(4, innerTemplate, 2, 2, 'div', [AttributeMarker.Template, 'ngIf']);
- }
- ɵɵelementEnd();
- }
-
- if (rf & RenderFlags.Update) {
- const app = ɵɵnextContext();
- const outerInput = ɵɵreference(1) as any;
- ɵɵtextBinding(1, ɵɵbind(outerInput.value));
- ɵɵelementProperty(4, 'ngIf', ɵɵbind(app.inner));
- }
- }
-
- function innerTemplate(rf: RenderFlags, inner: any) {
- if (rf & RenderFlags.Create) {
- ɵɵelementStart(0, 'div');
- { ɵɵtext(1); }
- ɵɵelementEnd();
- }
-
- if (rf & RenderFlags.Update) {
- ɵɵnextContext();
- const innerInput = ɵɵreference(3) as any;
- ɵɵnextContext();
- const outerInput = ɵɵreference(1) as any;
- ɵɵtextBinding(1, ɵɵinterpolation2('', outerInput.value, ' - ', innerInput.value, ''));
- }
- }
-
- const fixture = new ComponentFixture(App);
- fixture.component.outer = true;
- fixture.component.inner = true;
- fixture.update();
- expect(fixture.html)
- .toEqual(`
`);
- });
-
});
});