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

Commit

Permalink
fix(components): TranscludingComponentFactory passes a wrong element …
Browse files Browse the repository at this point in the history
…to onShadowRoot

Closes #1435

Closes #1436
  • Loading branch information
vsavkin committed Sep 14, 2014
1 parent 5f5ce35 commit 2c87e84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/core_dom/transcluding_component_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
var childInjectorCompleter; // Used if the ViewFuture is available before the childInjector.

var component = _component;
final shadowRoot = new EmulatedShadowRoot(element);
var lightDom = new LightDom(element, scope)..pullNodes();

final baseUrls = (_component.useNgBaseCss) ? baseCss.urls : [];
Expand All @@ -83,12 +84,12 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
lightDom.clearComponentElement();
if (childInjector != null) {
lightDom.shadowDomView = viewFactory.call(childInjector.scope, childInjector);
return element;
return shadowRoot;
} else {
childInjectorCompleter = new async.Completer();
return childInjectorCompleter.future.then((childInjector) {
lightDom.shadowDomView = viewFactory.call(childInjector.scope, childInjector);
return element;
return shadowRoot;
});
}
});
Expand All @@ -103,7 +104,7 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
Scope shadowScope = scope.createChild(new HashMap());

childInjector = new ComponentDirectiveInjector(injector, this._injector,
eventHandler, shadowScope, templateLoader, new EmulatedShadowRoot(element), lightDom, view);
eventHandler, shadowScope, templateLoader, shadowRoot, lightDom, view);

childInjector.bindByKey(_ref.typeKey, _ref.factory, _ref.paramKeys, _ref.annotation.visibility);

Expand Down
11 changes: 7 additions & 4 deletions test/core_dom/compiler_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,12 @@ void main() {
expect(logger).toEqual(expected);
logger.clear();

microLeap();
backend.flush();
microLeap();
expect(() {
microLeap();
backend.flush();
microLeap();
}).not.toThrow();

expect(logger).toEqual(['templateLoaded', _.rootScope.context['shadowRoot']]);
logger.clear();

Expand Down Expand Up @@ -1431,7 +1434,7 @@ class AttachDetachComponent implements AttachAware, DetachAware, ShadowRootAware

attach() => logger('attach:@$attrValue; =>$exprValue; =>!$onceValue');
detach() => logger('detach');
onShadowRoot(shadowRoot) {
onShadowRoot(ShadowRoot shadowRoot) {
scope.rootScope.context['shadowRoot'] = shadowRoot;
logger(shadowRoot);
}
Expand Down

0 comments on commit 2c87e84

Please sign in to comment.