Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ export class ElementBinderBuilder extends CompileStep {
var elementBinder = null;
if (current.hasBindings) {
var protoView = current.inheritedProtoView;
elementBinder = protoView.bindElement(current.inheritedProtoElementInjector,
var protoInjectorWasBuilt = isBlank(parent) ? true :
current.inheritedProtoElementInjector != parent.inheritedProtoElementInjector;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our convention is to use === and !==


var currentProtoElementInjector = protoInjectorWasBuilt ?
current.inheritedProtoElementInjector : null;

elementBinder = protoView.bindElement(currentProtoElementInjector,
current.componentDirective, current.templateDirective);

if (isPresent(current.textNodeBindings)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function main() {
var evalContext, view, changeDetector;

function createPipeline({textNodeBindings, propertyBindings, eventBindings, directives, protoElementInjector
}={}) {
}={}) {
var reflector = new DirectiveMetadataReader();
var parser = new Parser(new Lexer());
return new CompilePipeline([
Expand All @@ -52,9 +52,6 @@ export function main() {
});
hasBinding = true;
}
if (isPresent(protoElementInjector)) {
current.inheritedProtoElementInjector = protoElementInjector;
}
if (isPresent(current.element.getAttribute('directives'))) {
hasBinding = true;
for (var i=0; i<directives.length; i++) {
Expand All @@ -66,6 +63,13 @@ export function main() {
current.hasBindings = true;
DOM.addClass(current.element, 'ng-binding');
}
if (isPresent(protoElementInjector) &&
(isPresent(current.element.getAttribute('text-binding')) ||
isPresent(current.element.getAttribute('prop-binding')) ||
isPresent(current.element.getAttribute('directives')) ||
isPresent(current.element.getAttribute('event-binding')))) {
current.inheritedProtoElementInjector = protoElementInjector;
}
if (isPresent(current.element.getAttribute('viewroot'))) {
current.isViewRoot = true;
current.inheritedProtoView = new ProtoView(current.element,
Expand Down Expand Up @@ -114,13 +118,28 @@ export function main() {
var directives = [SomeDecoratorDirective];
var protoElementInjector = new ProtoElementInjector(null, 0, directives);

var pipeline = createPipeline({protoElementInjector: protoElementInjector, directives: directives});
var pipeline = createPipeline({protoElementInjector: protoElementInjector,
directives: directives});
var results = pipeline.process(el('<div viewroot directives></div>'));
var pv = results[0].inheritedProtoView;

expect(pv.elementBinders[0].protoElementInjector).toBe(protoElementInjector);
});

it('should not store the parent protoElementInjector', () => {
var directives = [SomeDecoratorDirective];
var eventBindings = MapWrapper.createFromStringMap({
'event1': '1+1'
});

var pipeline = createPipeline({directives: directives, eventBindings: eventBindings});
var results = pipeline.process(el('<div viewroot directives><div event-binding></div></div>'));
var pv = results[0].inheritedProtoView;

expect(pv.elementBinders[1].protoElementInjector).toBeNull();
});


it('should store the component directive', () => {
var directives = [SomeComponentDirective];
var pipeline = createPipeline({protoElementInjector: null, directives: directives});
Expand Down