Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

feat(directive-injector): component directive injector injects parent #1379

Closed
wants to merge 1 commit into from

Conversation

rkirov
Copy link
Contributor

@rkirov rkirov commented Aug 22, 2014

When asked for DirectiveInjector, ComponentDirectiveInjector injects
parent and injects self, when asked for ComponentDirectiveInjector
explicitly.

Closes #1351

@mhevery mhevery added cla: yes and removed cla: no labels Aug 22, 2014
DirectiveInjector i;
ComponentDirectiveInjector cdi;
InjectorDependentComponent(this.i, this.cdi) {
expect(i).not.toEqual(cdi);
Copy link
Contributor

Choose a reason for hiding this comment

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

expect(i).toBeAnInstanceOf(DirectiveInjector);
expect(cdi).toBeAnInstanceOf(ComponentDirectiveInjector);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added.

@vicb
Copy link
Contributor

vicb commented Aug 22, 2014

IIUC and if this is a "feat" (not a 'fix") the commit message should mention that it is a breaking change as inj.getByKey(DIRECTIVE_INJECTOR) now returns the parent. This should also be tested.

@rkirov
Copy link
Contributor Author

rkirov commented Aug 22, 2014

Adding breaking change line. Note inj.getByKey(DIRECTIVE_INJECTOR) returns parent only if inj is a ComponentDirectiveInjector. There are no changes made to DirectiveInjector.

I am not following your comment about "this should be tested" as there is a test.

@vicb
Copy link
Contributor

vicb commented Aug 23, 2014

I think the new behavior should be tested: "inj.getByKey(DIRECTIVE_INJECTOR) returns parent only if inj is a ComponentDirectiveInjector" -> we should test that it returns the parent as the behavior was different before

BREAKING_CHANGE:
When asked for DirectiveInjector, ComponentDirectiveInjector injects
parent. When asked for ComponentDirectiveInjector it injects self.

Before:
MyComponent(DirectiveInjector di) { }

After:
MyComponent(ComponentDirectiveInjector cdi, DirectiveInjector di) { }

where before di = after cdi, before di.parent = after di.

Closes dart-archive#1351
@rkirov
Copy link
Contributor Author

rkirov commented Aug 25, 2014

Added expect(cdi.parent).toBe(i); should be good to go.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

ComponentDirectiveInjector should return this.parent when asked for DirectiveInjector
4 participants