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

Commit 2c87e84

Browse files
committed
fix(components): TranscludingComponentFactory passes a wrong element to onShadowRoot
Closes #1435 Closes #1436
1 parent 5f5ce35 commit 2c87e84

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/core_dom/transcluding_component_factory.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
7171
var childInjectorCompleter; // Used if the ViewFuture is available before the childInjector.
7272

7373
var component = _component;
74+
final shadowRoot = new EmulatedShadowRoot(element);
7475
var lightDom = new LightDom(element, scope)..pullNodes();
7576

7677
final baseUrls = (_component.useNgBaseCss) ? baseCss.urls : [];
@@ -83,12 +84,12 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
8384
lightDom.clearComponentElement();
8485
if (childInjector != null) {
8586
lightDom.shadowDomView = viewFactory.call(childInjector.scope, childInjector);
86-
return element;
87+
return shadowRoot;
8788
} else {
8889
childInjectorCompleter = new async.Completer();
8990
return childInjectorCompleter.future.then((childInjector) {
9091
lightDom.shadowDomView = viewFactory.call(childInjector.scope, childInjector);
91-
return element;
92+
return shadowRoot;
9293
});
9394
}
9495
});
@@ -103,7 +104,7 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
103104
Scope shadowScope = scope.createChild(new HashMap());
104105

105106
childInjector = new ComponentDirectiveInjector(injector, this._injector,
106-
eventHandler, shadowScope, templateLoader, new EmulatedShadowRoot(element), lightDom, view);
107+
eventHandler, shadowScope, templateLoader, shadowRoot, lightDom, view);
107108

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

test/core_dom/compiler_spec.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,12 @@ void main() {
816816
expect(logger).toEqual(expected);
817817
logger.clear();
818818

819-
microLeap();
820-
backend.flush();
821-
microLeap();
819+
expect(() {
820+
microLeap();
821+
backend.flush();
822+
microLeap();
823+
}).not.toThrow();
824+
822825
expect(logger).toEqual(['templateLoaded', _.rootScope.context['shadowRoot']]);
823826
logger.clear();
824827

@@ -1431,7 +1434,7 @@ class AttachDetachComponent implements AttachAware, DetachAware, ShadowRootAware
14311434

14321435
attach() => logger('attach:@$attrValue; =>$exprValue; =>!$onceValue');
14331436
detach() => logger('detach');
1434-
onShadowRoot(shadowRoot) {
1437+
onShadowRoot(ShadowRoot shadowRoot) {
14351438
scope.rootScope.context['shadowRoot'] = shadowRoot;
14361439
logger(shadowRoot);
14371440
}

0 commit comments

Comments
 (0)