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

Commit 22cf079

Browse files
committed
fix(components): TranscludingComponentFactory passes a wrong element to onShadowRoot
Closes #1435
1 parent f14cc71 commit 22cf079

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/core_dom/transcluding_component_factory.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
5353
var childInjectorCompleter; // Used if the ViewFuture is available before the childInjector.
5454

5555
var component = _component;
56-
var lightDom = new LightDom(element, scope);
56+
final shadowRoot = new EmulatedShadowRoot(element);
57+
final lightDom = new LightDom(element, scope);
5758

5859
// Append the component's template as children
5960
var elementFuture;
@@ -64,12 +65,12 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
6465

6566
if (childInjector != null) {
6667
lightDom.shadowDomView = viewFactory.call(childInjector.scope, childInjector);
67-
return element;
68+
return shadowRoot;
6869
} else {
6970
childInjectorCompleter = new async.Completer();
7071
return childInjectorCompleter.future.then((childInjector) {
7172
lightDom.shadowDomView = viewFactory.call(childInjector.scope, childInjector);
72-
return element;
73+
return shadowRoot;
7374
});
7475
}
7576
});
@@ -81,7 +82,7 @@ class BoundTranscludingComponentFactory implements BoundComponentFactory {
8182
Scope shadowScope = scope.createChild(new HashMap());
8283

8384
childInjector = new ComponentDirectiveInjector(injector, this._injector,
84-
eventHandler, shadowScope, templateLoader, new EmulatedShadowRoot(element), lightDom, view);
85+
eventHandler, shadowScope, templateLoader, shadowRoot, lightDom, view);
8586

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

test/core_dom/compiler_spec.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,12 @@ void main() {
788788
expect(logger).toEqual(expected);
789789
logger.clear();
790790

791-
microLeap();
792-
backend.flush();
793-
microLeap();
791+
expect(() {
792+
microLeap();
793+
backend.flush();
794+
microLeap();
795+
}).not.toThrow();
796+
794797
expect(logger).toEqual(['templateLoaded', _.rootScope.context['shadowRoot']]);
795798
logger.clear();
796799

@@ -1403,7 +1406,7 @@ class AttachDetachComponent implements AttachAware, DetachAware, ShadowRootAware
14031406

14041407
attach() => logger('attach:@$attrValue; =>$exprValue; =>!$onceValue');
14051408
detach() => logger('detach');
1406-
onShadowRoot(shadowRoot) {
1409+
onShadowRoot(ShadowRoot shadowRoot) {
14071410
scope.rootScope.context['shadowRoot'] = shadowRoot;
14081411
logger(shadowRoot);
14091412
}

0 commit comments

Comments
 (0)