diff --git a/lib/core_dom/transcluding_component_factory.dart b/lib/core_dom/transcluding_component_factory.dart index 7ef30eedb..551a66765 100644 --- a/lib/core_dom/transcluding_component_factory.dart +++ b/lib/core_dom/transcluding_component_factory.dart @@ -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 : []; @@ -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; }); } }); @@ -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); diff --git a/test/core_dom/compiler_spec.dart b/test/core_dom/compiler_spec.dart index 7d06adfff..ed838b376 100644 --- a/test/core_dom/compiler_spec.dart +++ b/test/core_dom/compiler_spec.dart @@ -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(); @@ -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); }