From d7326d81ba1ca0fb2bb84fe2fa97c4806219102c Mon Sep 17 00:00:00 2001 From: Andrew Kushnir Date: Wed, 26 Sep 2018 14:33:48 -0700 Subject: [PATCH] fixup! feat(ivy): adding support for ngNonBindable attribute --- .../r3_view_compiler_binding_spec.ts | 6 +-- .../compiler/src/render3/r3_identifiers.ts | 3 +- .../compiler/src/render3/view/template.ts | 5 +- .../core/test/render3/integration_spec.ts | 50 +++++++++---------- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts b/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts index e9c5246f8e..d5b8ec26a9 100644 --- a/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts +++ b/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts @@ -171,8 +171,7 @@ describe('compiler compliance: bindings', () => { } `; const result = compile(files, angularFiles); - expectEmit(result.source, template, - 'Incorrect handling of local refs for host element'); + expectEmit(result.source, template, 'Incorrect handling of local refs for host element'); }); it('should not have local refs for nested elements', () => { @@ -196,8 +195,7 @@ describe('compiler compliance: bindings', () => { } `; const result = compile(files, angularFiles); - expectEmit(result.source, template, - 'Incorrect handling of local refs for nested elements'); + expectEmit(result.source, template, 'Incorrect handling of local refs for nested elements'); }); }); diff --git a/packages/compiler/src/render3/r3_identifiers.ts b/packages/compiler/src/render3/r3_identifiers.ts index 5faddc5b20..ae76754a84 100644 --- a/packages/compiler/src/render3/r3_identifiers.ts +++ b/packages/compiler/src/render3/r3_identifiers.ts @@ -62,7 +62,8 @@ export class Identifiers { static setBindingsEnabled: o.ExternalReference = {name: 'ɵsetBindingsEnabled', moduleName: CORE}; - static setBindingsDisabled: o.ExternalReference = {name: 'ɵsetBindingsDisabled', moduleName: CORE}; + static setBindingsDisabled: + o.ExternalReference = {name: 'ɵsetBindingsDisabled', moduleName: CORE}; static getCurrentView: o.ExternalReference = {name: 'ɵgetCurrentView', moduleName: CORE}; diff --git a/packages/compiler/src/render3/view/template.ts b/packages/compiler/src/render3/view/template.ts index 37ade39b8a..785c065f0a 100644 --- a/packages/compiler/src/render3/view/template.ts +++ b/packages/compiler/src/render3/view/template.ts @@ -30,7 +30,7 @@ import {htmlAstToRender3Ast} from '../r3_template_transform'; import {R3QueryMetadata} from './api'; import {parseStyle} from './styling'; -import {CONTEXT_NAME, NON_BINDABLE_ATTR, I18N_ATTR, I18N_ATTR_PREFIX, ID_SEPARATOR, IMPLICIT_REFERENCE, MEANING_SEPARATOR, REFERENCE_PREFIX, RENDER_FLAGS, asLiteral, invalid, isI18NAttribute, mapToExpression, trimTrailingNulls, unsupported} from './util'; +import {CONTEXT_NAME, I18N_ATTR, I18N_ATTR_PREFIX, ID_SEPARATOR, IMPLICIT_REFERENCE, MEANING_SEPARATOR, NON_BINDABLE_ATTR, REFERENCE_PREFIX, RENDER_FLAGS, asLiteral, invalid, isI18NAttribute, mapToExpression, trimTrailingNulls, unsupported} from './util'; function mapBindingToInstruction(type: BindingType): o.ExternalReference|undefined { switch (type) { @@ -662,8 +662,7 @@ export class TemplateDefinitionBuilder implements t.Visitor, LocalResolver // Finish element construction mode. if (isNonBindableMode) { this.creationInstruction( - element.endSourceSpan || element.sourceSpan, - R3.setBindingsEnabled); + element.endSourceSpan || element.sourceSpan, R3.setBindingsEnabled); } this.creationInstruction( element.endSourceSpan || element.sourceSpan, diff --git a/packages/core/test/render3/integration_spec.ts b/packages/core/test/render3/integration_spec.ts index 617890bc1a..f8ac7bf7c1 100644 --- a/packages/core/test/render3/integration_spec.ts +++ b/packages/core/test/render3/integration_spec.ts @@ -7,7 +7,7 @@ */ import {ElementRef, TemplateRef, ViewContainerRef} from '@angular/core'; -import {reference, RenderFlags} from '@angular/core/src/render3'; +import {RenderFlags, reference} from '@angular/core/src/render3'; import {RendererStyleFlags2, RendererType2} from '../../src/render/api'; import {AttributeMarker, defineComponent, defineDirective} from '../../src/render3/index'; @@ -144,17 +144,17 @@ describe('render3 integration test', () => { const App = createComponent('app', function(rf: RenderFlags, ctx: any) { if (rf & RenderFlags.Create) { elementStart(0, 'b', ['id', 'my-id'], ['myRef', '']); - setBindingsDisabled(); - elementStart(2, 'i'); - text(3, 'Hello {{ name }}!'); - elementEnd(); - setBindingsEnabled(); + setBindingsDisabled(); + elementStart(2, 'i'); + text(3, 'Hello {{ name }}!'); + elementEnd(); + setBindingsEnabled(); elementEnd(); text(4); } if (rf & RenderFlags.Update) { const ref = reference(1) as any; - textBinding(4, interpolation1(" ", ref.id, " ")); + textBinding(4, interpolation1(' ', ref.id, ' ')); } }, 5, 1); @@ -171,10 +171,10 @@ describe('render3 integration test', () => { const App = createComponent('app', function(rf: RenderFlags, ctx: any) { if (rf & RenderFlags.Create) { elementStart(0, 'div'); - setBindingsDisabled(); - element(1, 'input', ['value', 'one']); - text(2, '{{ myInput.value }}'); - setBindingsEnabled(); + setBindingsDisabled(); + element(1, 'input', ['value', 'one']); + text(2, '{{ myInput.value }}'); + setBindingsEnabled(); elementEnd(); } }, 3, 0); @@ -187,9 +187,7 @@ describe('render3 integration test', () => { let directiveInvoked: boolean = false; class TestDirective { - ngOnInit() { - directiveInvoked = true; - } + ngOnInit() { directiveInvoked = true; } static ngDirectiveDef = defineDirective({ type: TestDirective, @@ -206,11 +204,11 @@ describe('render3 integration test', () => { const App = createComponent('app', function(rf: RenderFlags, ctx: any) { if (rf & RenderFlags.Create) { elementStart(0, 'b', ['directive', '']); - setBindingsDisabled(); - elementStart(1, 'i'); - text(2, 'Hello {{ name }}!'); - elementEnd(); - setBindingsEnabled(); + setBindingsDisabled(); + elementStart(1, 'i'); + text(2, 'Hello {{ name }}!'); + elementEnd(); + setBindingsEnabled(); elementEnd(); } }, 3, 0, [TestDirective]); @@ -224,9 +222,7 @@ describe('render3 integration test', () => { let directiveInvoked: boolean = false; class TestDirective { - ngOnInit() { - directiveInvoked = true; - } + ngOnInit() { directiveInvoked = true; } static ngDirectiveDef = defineDirective({ type: TestDirective, @@ -243,11 +239,11 @@ describe('render3 integration test', () => { const App = createComponent('app', function(rf: RenderFlags, ctx: any) { if (rf & RenderFlags.Create) { elementStart(0, 'b'); - setBindingsDisabled(); - elementStart(1, 'i', ['directive', '']); - text(2, 'Hello {{ name }}!'); - elementEnd(); - setBindingsEnabled(); + setBindingsDisabled(); + elementStart(1, 'i', ['directive', '']); + text(2, 'Hello {{ name }}!'); + elementEnd(); + setBindingsEnabled(); elementEnd(); } }, 3, 0, [TestDirective]);