@@ -26,7 +26,7 @@ export function main() {
2626 var evalContext , view , changeDetector ;
2727
2828 function createPipeline ( { textNodeBindings, propertyBindings, eventBindings, directives, protoElementInjector
29- } = { } ) {
29+ } = { } ) {
3030 var reflector = new DirectiveMetadataReader ( ) ;
3131 var parser = new Parser ( new Lexer ( ) ) ;
3232 return new CompilePipeline ( [
@@ -52,9 +52,6 @@ export function main() {
5252 } ) ;
5353 hasBinding = true ;
5454 }
55- if ( isPresent ( protoElementInjector ) ) {
56- current . inheritedProtoElementInjector = protoElementInjector ;
57- }
5855 if ( isPresent ( current . element . getAttribute ( 'directives' ) ) ) {
5956 hasBinding = true ;
6057 for ( var i = 0 ; i < directives . length ; i ++ ) {
@@ -66,6 +63,13 @@ export function main() {
6663 current . hasBindings = true ;
6764 DOM . addClass ( current . element , 'ng-binding' ) ;
6865 }
66+ if ( isPresent ( protoElementInjector ) &&
67+ ( isPresent ( current . element . getAttribute ( 'text-binding' ) ) ||
68+ isPresent ( current . element . getAttribute ( 'prop-binding' ) ) ||
69+ isPresent ( current . element . getAttribute ( 'directives' ) ) ||
70+ isPresent ( current . element . getAttribute ( 'event-binding' ) ) ) ) {
71+ current . inheritedProtoElementInjector = protoElementInjector ;
72+ }
6973 if ( isPresent ( current . element . getAttribute ( 'viewroot' ) ) ) {
7074 current . isViewRoot = true ;
7175 current . inheritedProtoView = new ProtoView ( current . element ,
@@ -114,13 +118,28 @@ export function main() {
114118 var directives = [ SomeDecoratorDirective ] ;
115119 var protoElementInjector = new ProtoElementInjector ( null , 0 , directives ) ;
116120
117- var pipeline = createPipeline ( { protoElementInjector : protoElementInjector , directives : directives } ) ;
121+ var pipeline = createPipeline ( { protoElementInjector : protoElementInjector ,
122+ directives : directives } ) ;
118123 var results = pipeline . process ( el ( '<div viewroot directives></div>' ) ) ;
119124 var pv = results [ 0 ] . inheritedProtoView ;
120125
121126 expect ( pv . elementBinders [ 0 ] . protoElementInjector ) . toBe ( protoElementInjector ) ;
122127 } ) ;
123128
129+ it ( 'should not store the parent protoElementInjector' , ( ) => {
130+ var directives = [ SomeDecoratorDirective ] ;
131+ var eventBindings = MapWrapper . createFromStringMap ( {
132+ 'event1' : '1+1'
133+ } ) ;
134+
135+ var pipeline = createPipeline ( { directives : directives , eventBindings : eventBindings } ) ;
136+ var results = pipeline . process ( el ( '<div viewroot directives><div event-binding></div></div>' ) ) ;
137+ var pv = results [ 0 ] . inheritedProtoView ;
138+
139+ expect ( pv . elementBinders [ 1 ] . protoElementInjector ) . toBeNull ( ) ;
140+ } ) ;
141+
142+
124143 it ( 'should store the component directive' , ( ) => {
125144 var directives = [ SomeComponentDirective ] ;
126145 var pipeline = createPipeline ( { protoElementInjector : null , directives : directives } ) ;
0 commit comments