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

Nested views injection fix #1244

Closed
wants to merge 1 commit into from
Closed

Conversation

rkirov
Copy link
Contributor

@rkirov rkirov commented Jul 19, 2014

forceNewDirectivesAndFormatters is now respecting inheritance for directive and application injectors.

@mhevery
Copy link
Contributor

mhevery commented Jul 21, 2014

Discussed with @rkirov and we decided that we need a better fix. Helped him create a better test, he is working on the proper fix.

final Node _node;
final NodeAttrs _nodeAttrs;
final Animate _animate;
final EventHandler _eventHandler;
final EventHandler eventHandler;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

rkirov added a commit that referenced this pull request Jul 24, 2014
Replace DefaultDirectiveInjector with DirectiveInjector (with parent = null).

Application Injector reference is passed through view creation and
passed into new Directive Injector (instead of using
parentInjector.appInjector, which is wrong).

New public method on dependency injector - parentGet. Allowing to get
through the usual chain but skipping itself (used for NgControl).

Remove EventListener from View.

Closes #1244
@rkirov rkirov closed this in 13d92b7 Jul 24, 2014
rkirov added a commit that referenced this pull request Jul 24, 2014
Replace DefaultDirectiveInjector with DirectiveInjector (with parent = null).

Application Injector reference is passed through view creation and
passed into new Directive Injector (instead of using
parentInjector.appInjector, which is wrong).

New public method on dependency injector - parentGet. Allowing to get
through the usual chain but skipping itself (used for NgControl).

Remove EventListener from View.

Closes #1244
@@ -64,7 +64,6 @@ part 'ng_model_options.dart';
*/
class DirectiveModule extends Module {
DirectiveModule() {
bind(DirectiveInjector, toImplementation: DefaultDirectiveInjector);
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to bind something to DirectiveInjector.  Currently, this fails with an error that there is no provider for DirectiveInjector in an application that I'm upgrading to support this change (after replacing all .parent.get with .parentGet.)

@chirayuk
Copy link
Contributor

This commit provides no default implementation for DirectiveInjector causing an exception.  I'm reverting it from master and reopening this PR.

@chirayuk chirayuk reopened this Jul 25, 2014
chirayuk added a commit that referenced this pull request Jul 25, 2014
…d views"

This reverts 59323da.

Without a default implementation for DirectiveInjector, this results in
a runtime exception (no provider found.)

Issue #1244
chirayuk added a commit that referenced this pull request Jul 25, 2014
…d views"

This reverts 59323da.

Without a default implementation for DirectiveInjector, this results in
a runtime exception (no provider found.)

Issue #1244
@rkirov rkirov mentioned this pull request Jul 28, 2014
2 tasks
get parent => this._parent;

// Same behavior as get but skips the current injector.
Object parentGet(Type type) => parentGetByKey(new Key(type));
Copy link
Contributor

Choose a reason for hiding this comment

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

what about getFromParent(ByKey) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. In fact, injector.parent seems to be widely used, so I will introduce these new APIs first in a separate PR, so that the apps can be switched away from injector.parent landing this significantly bigger PR.

@rkirov
Copy link
Contributor Author

rkirov commented Aug 19, 2014

rebased.
@vsavkin I see you are making changes around some parts of the same code. Let me know if what I am doing here is still sound on top of your changes.

I handled all the clients breakage by moving them to the new APIs (getFromParent), so this should be ready to submit.

@vsavkin
Copy link
Contributor

vsavkin commented Aug 20, 2014

@rkirov yup, I had a few PRs touching the same code. From what I can see there will be quite a few conflicts, but nothing incompatible.

Breaking change: Regular (application) injectors cannot construct
DirectiveInjectors (DI). Only compilers create DI as part of view
creation process.

Deprecation: directive injector parent is now private. New public
method on dependency injector - parentGet, which allows to get through the
usual chain but skipping itself.

Component Injectors now break the resolution chain (except when called
directly.)

TestBed does not need DI in its constructor.

Internal changes:
- Application Injector reference is passed through view creation and
passed into new Directive Injector (instead of using
parentInjector.appInjector, which is wrong when used with ng-view).
- Unwind recursion from the directive injector.
- Remove EventListener from View.
- Replace DefaultDirectiveInjector with DirectiveInjector (with parent = null).
- Component visibility handled outside the visibility enum.
- Removed Shadowless and ShadowDirectiveInjector subclasses.

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

rkirov commented Aug 27, 2014

Merged last week as 600113a

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

Successfully merging this pull request may close these issues.

6 participants