fixup! feat(ivy): adding support for ngNonBindable attribute

This commit is contained in:
Andrew Kushnir 2018-09-26 14:33:48 -07:00 committed by Alex Rickabaugh
parent c683f74225
commit d7326d81ba
4 changed files with 29 additions and 35 deletions

View File

@ -171,8 +171,7 @@ describe('compiler compliance: bindings', () => {
} }
`; `;
const result = compile(files, angularFiles); const result = compile(files, angularFiles);
expectEmit(result.source, template, expectEmit(result.source, template, 'Incorrect handling of local refs for host element');
'Incorrect handling of local refs for host element');
}); });
it('should not have local refs for nested elements', () => { it('should not have local refs for nested elements', () => {
@ -196,8 +195,7 @@ describe('compiler compliance: bindings', () => {
} }
`; `;
const result = compile(files, angularFiles); const result = compile(files, angularFiles);
expectEmit(result.source, template, expectEmit(result.source, template, 'Incorrect handling of local refs for nested elements');
'Incorrect handling of local refs for nested elements');
}); });
}); });

View File

@ -62,7 +62,8 @@ export class Identifiers {
static setBindingsEnabled: o.ExternalReference = {name: 'ɵsetBindingsEnabled', moduleName: CORE}; 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}; static getCurrentView: o.ExternalReference = {name: 'ɵgetCurrentView', moduleName: CORE};

View File

@ -30,7 +30,7 @@ import {htmlAstToRender3Ast} from '../r3_template_transform';
import {R3QueryMetadata} from './api'; import {R3QueryMetadata} from './api';
import {parseStyle} from './styling'; 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 { function mapBindingToInstruction(type: BindingType): o.ExternalReference|undefined {
switch (type) { switch (type) {
@ -662,8 +662,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
// Finish element construction mode. // Finish element construction mode.
if (isNonBindableMode) { if (isNonBindableMode) {
this.creationInstruction( this.creationInstruction(
element.endSourceSpan || element.sourceSpan, element.endSourceSpan || element.sourceSpan, R3.setBindingsEnabled);
R3.setBindingsEnabled);
} }
this.creationInstruction( this.creationInstruction(
element.endSourceSpan || element.sourceSpan, element.endSourceSpan || element.sourceSpan,

View File

@ -7,7 +7,7 @@
*/ */
import {ElementRef, TemplateRef, ViewContainerRef} from '@angular/core'; 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 {RendererStyleFlags2, RendererType2} from '../../src/render/api';
import {AttributeMarker, defineComponent, defineDirective} from '../../src/render3/index'; 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) { const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) { if (rf & RenderFlags.Create) {
elementStart(0, 'b', ['id', 'my-id'], ['myRef', '']); elementStart(0, 'b', ['id', 'my-id'], ['myRef', '']);
setBindingsDisabled(); setBindingsDisabled();
elementStart(2, 'i'); elementStart(2, 'i');
text(3, 'Hello {{ name }}!'); text(3, 'Hello {{ name }}!');
elementEnd(); elementEnd();
setBindingsEnabled(); setBindingsEnabled();
elementEnd(); elementEnd();
text(4); text(4);
} }
if (rf & RenderFlags.Update) { if (rf & RenderFlags.Update) {
const ref = reference(1) as any; const ref = reference(1) as any;
textBinding(4, interpolation1(" ", ref.id, " ")); textBinding(4, interpolation1(' ', ref.id, ' '));
} }
}, 5, 1); }, 5, 1);
@ -171,10 +171,10 @@ describe('render3 integration test', () => {
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'); elementStart(0, 'div');
setBindingsDisabled(); setBindingsDisabled();
element(1, 'input', ['value', 'one']); element(1, 'input', ['value', 'one']);
text(2, '{{ myInput.value }}'); text(2, '{{ myInput.value }}');
setBindingsEnabled(); setBindingsEnabled();
elementEnd(); elementEnd();
} }
}, 3, 0); }, 3, 0);
@ -187,9 +187,7 @@ describe('render3 integration test', () => {
let directiveInvoked: boolean = false; let directiveInvoked: boolean = false;
class TestDirective { class TestDirective {
ngOnInit() { ngOnInit() { directiveInvoked = true; }
directiveInvoked = true;
}
static ngDirectiveDef = defineDirective({ static ngDirectiveDef = defineDirective({
type: TestDirective, type: TestDirective,
@ -206,11 +204,11 @@ describe('render3 integration test', () => {
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, 'b', ['directive', '']); elementStart(0, 'b', ['directive', '']);
setBindingsDisabled(); setBindingsDisabled();
elementStart(1, 'i'); elementStart(1, 'i');
text(2, 'Hello {{ name }}!'); text(2, 'Hello {{ name }}!');
elementEnd(); elementEnd();
setBindingsEnabled(); setBindingsEnabled();
elementEnd(); elementEnd();
} }
}, 3, 0, [TestDirective]); }, 3, 0, [TestDirective]);
@ -224,9 +222,7 @@ describe('render3 integration test', () => {
let directiveInvoked: boolean = false; let directiveInvoked: boolean = false;
class TestDirective { class TestDirective {
ngOnInit() { ngOnInit() { directiveInvoked = true; }
directiveInvoked = true;
}
static ngDirectiveDef = defineDirective({ static ngDirectiveDef = defineDirective({
type: TestDirective, type: TestDirective,
@ -243,11 +239,11 @@ describe('render3 integration test', () => {
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, 'b'); elementStart(0, 'b');
setBindingsDisabled(); setBindingsDisabled();
elementStart(1, 'i', ['directive', '']); elementStart(1, 'i', ['directive', '']);
text(2, 'Hello {{ name }}!'); text(2, 'Hello {{ name }}!');
elementEnd(); elementEnd();
setBindingsEnabled(); setBindingsEnabled();
elementEnd(); elementEnd();
} }
}, 3, 0, [TestDirective]); }, 3, 0, [TestDirective]);