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

Commit

Permalink
fix(component): revert regression of injecting Element/Node into Comp…
Browse files Browse the repository at this point in the history
…onent
  • Loading branch information
mhevery committed Mar 19, 2014
1 parent 4e4415e commit d9fc724
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/core_dom/event_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,11 @@ class EventHandler {
return part.replaceAll("-", "");
}
}

@NgInjectableService()
class _ShadowRootEventHandler extends EventHandler {
_ShadowRootEventHandler(dom.ShadowRoot shadowRoot,
Expando expando,
ExceptionHandler exceptionHandler)
: super(shadowRoot, expando, exceptionHandler);
}
4 changes: 1 addition & 3 deletions lib/core_dom/view_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,10 @@ class _ComponentFactory implements Function {
var shadowModule = new Module()
..type(type)
..type(NgElement)
..type(EventHandler)
..type(EventHandler, implementedBy: _ShadowRootEventHandler)
..value(Scope, shadowScope)
..value(TemplateLoader, templateLoader)
..value(dom.ShadowRoot, shadowDom)
..value(dom.Element, null)
..value(dom.Node, shadowDom)
..factory(ElementProbe, (_) => probe);
shadowInjector = injector.createChild([shadowModule], name: _SHADOW);
probe = _expando[shadowDom] = new ElementProbe(
Expand Down
20 changes: 20 additions & 0 deletions test/core_dom/compiler_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void main() {
..type(SimpleAttachComponent)
..type(SimpleComponent)
..type(ExprAttrComponent)
..type(LogElementComponent)
..type(SayHelloFilter);
});

Expand Down Expand Up @@ -521,6 +522,13 @@ void main() {

expect(logger).toEqual(['SimpleAttachComponent']);
}));

it('should inject compenent element as the dom.Element', async((Logger log, TestBed _, MockHttpBackend backend) {
backend.whenGET('foo.html').respond('<div>WORKED</div>');
_.compile('<log-element></log-element>');
Element element = _.rootElement;
expect(log).toEqual([element, element, element.shadowRoot]);
}));
});

describe('invalid components', () {
Expand Down Expand Up @@ -941,3 +949,15 @@ class SimpleAttachComponent implements NgAttachAware, NgShadowRootAware {
attach() => logger('attach');
onShadowRoot(_) => logger('onShadowRoot');
}

@NgComponent(
selector: 'log-element',
templateUrl: 'foo.html')
class LogElementComponent{
LogElementComponent(Logger logger, Element element, Node node,
ShadowRoot shadowRoot) {
logger(element);
logger(node);
logger(shadowRoot);
}
}

0 comments on commit d9fc724

Please sign in to comment.