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

This commit is contained in:
Misko Hevery
2018-09-26 21:09:03 -07:00
committed by Alex Rickabaugh
parent add1198b88
commit 632b19d5c2
8 changed files with 73 additions and 31 deletions

View File

@ -84,8 +84,8 @@ export {
elementProperty as ɵelementProperty,
projectionDef as ɵprojectionDef,
reference as ɵreference,
setBindingsEnabled as ɵsetBindingsEnabled,
setBindingsDisabled as ɵsetBindingsDisabled,
enableBindings as ɵenableBindings,
disableBindings as ɵdisableBindings,
elementAttribute as ɵelementAttribute,
elementStyling as ɵelementStyling,
elementStylingMap as ɵelementStylingMap,

View File

@ -67,8 +67,8 @@ export {
namespaceMathML,
namespaceSVG,
setBindingsEnabled,
setBindingsDisabled,
enableBindings,
disableBindings,
projection,
projectionDef,

View File

@ -99,6 +99,24 @@ export function getCurrentSanitizer(): Sanitizer|null {
*/
let elementDepthCount !: number;
/**
* Stores wether directives should be matched to elements.
*
* When template contains `ngNonBindable` than we need to prevent the runtime form matching
* directives on children of that element.
*
* Example:
* ```
* <my-comp my-directive>
* Should match component / directive.
* </my-comp>
* <div ngNonBindable>
* <my-comp my-directive>
* Should not match component / directive because we are in ngNonBindable.
* </my-comp>
* </div>
* ```
*/
let bindingsEnabled !: boolean;
/**
@ -1399,18 +1417,44 @@ export function elementProperty<T>(
}
/**
* Enables bindings processing for further instructions
* (used while processing "ngNonBindable" element's attribute).
* Enables directive matching on elements.
*
* * Example:
* ```
* <my-comp my-directive>
* Should match component / directive.
* </my-comp>
* <div ngNonBindable>
* <!-- disabledBindings() -->
* <my-comp my-directive>
* Should not match component / directive because we are in ngNonBindable.
* </my-comp>
* <!-- enableBindings() -->
* </div>
* ```
*/
export function setBindingsEnabled(): void {
export function enableBindings(): void {
bindingsEnabled = true;
}
/**
* Disables bindings processing for further instructions
* (used while processing "ngNonBindable" element's attribute).
* Disables directive matching on element.
*
* * Example:
* ```
* <my-comp my-directive>
* Should match component / directive.
* </my-comp>
* <div ngNonBindable>
* <!-- disabledBindings() -->
* <my-comp my-directive>
* Should not match component / directive because we are in ngNonBindable.
* </my-comp>
* <!-- enableBindings() -->
* </div>
* ```
*/
export function setBindingsDisabled(): void {
export function disableBindings(): void {
bindingsEnabled = false;
}

View File

@ -46,8 +46,8 @@ export const angularCoreEnv: {[name: string]: Function} = {
'ɵnamespaceHTML': r3.namespaceHTML,
'ɵnamespaceMathML': r3.namespaceMathML,
'ɵnamespaceSVG': r3.namespaceSVG,
setBindingsEnabled': r3.setBindingsEnabled,
setBindingsDisabled': r3.setBindingsDisabled,
enableBindings': r3.enableBindings,
disableBindings': r3.disableBindings,
'ɵelementStart': r3.elementStart,
'ɵelementEnd': r3.elementEnd,
'ɵelement': r3.element,

View File

@ -11,7 +11,7 @@ import {ElementRef, TemplateRef, ViewContainerRef} from '@angular/core';
import {RendererStyleFlags2, RendererType2} from '../../src/render/api';
import {AttributeMarker, defineComponent, defineDirective} from '../../src/render3/index';
import {NO_CHANGE, bind, container, containerRefreshEnd, containerRefreshStart, element, elementAttribute, elementClassProp, elementContainerEnd, elementContainerStart, elementEnd, elementProperty, elementStart, elementStyleProp, elementStyling, elementStylingApply, embeddedViewEnd, embeddedViewStart, setBindingsEnabled, setBindingsDisabled, interpolation1, interpolation2, interpolation3, interpolation4, interpolation5, interpolation6, interpolation7, interpolation8, interpolationV, listener, load, loadDirective, projection, projectionDef, reference, text, textBinding, template} from '../../src/render3/instructions';
import {NO_CHANGE, bind, container, containerRefreshEnd, containerRefreshStart, element, elementAttribute, elementClassProp, elementContainerEnd, elementContainerStart, elementEnd, elementProperty, elementStart, elementStyleProp, elementStyling, elementStylingApply, embeddedViewEnd, embeddedViewStart, enableBindings, disableBindings, interpolation1, interpolation2, interpolation3, interpolation4, interpolation5, interpolation6, interpolation7, interpolation8, interpolationV, listener, load, loadDirective, projection, projectionDef, reference, text, textBinding, template} from '../../src/render3/instructions';
import {InitialStylingFlags, RenderFlags} from '../../src/render3/interfaces/definition';
import {RElement, Renderer3, RendererFactory3, domRendererFactory3, RText, RComment, RNode, RendererStyleFlags3, ProceduralRenderer3} from '../../src/render3/interfaces/renderer';
import {HEADER_OFFSET, CONTEXT, DIRECTIVES} from '../../src/render3/interfaces/view';
@ -143,11 +143,11 @@ 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();
disableBindings();
elementStart(2, 'i');
text(3, 'Hello {{ name }}!');
elementEnd();
setBindingsEnabled();
enableBindings();
elementEnd();
text(4);
}
@ -182,11 +182,11 @@ describe('render3 integration test', () => {
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) {
elementStart(0, 'b', ['directive', '']);
setBindingsDisabled();
disableBindings();
elementStart(1, 'i');
text(2, 'Hello {{ name }}!');
elementEnd();
setBindingsEnabled();
enableBindings();
elementEnd();
}
}, 3, 0, [TestDirective]);
@ -217,11 +217,11 @@ describe('render3 integration test', () => {
const App = createComponent('app', function(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) {
elementStart(0, 'b');
setBindingsDisabled();
disableBindings();
elementStart(1, 'i', ['directive', '']);
text(2, 'Hello {{ name }}!');
elementEnd();
setBindingsEnabled();
enableBindings();
elementEnd();
}
}, 3, 0, [TestDirective]);