parent
e725542703
commit
231773ea76
@ -433,8 +433,9 @@ class TemplateParseVisitor implements HtmlAstVisitor {
|
|||||||
var parts = splitAtColon(name, [null, name]);
|
var parts = splitAtColon(name, [null, name]);
|
||||||
var target = parts[0];
|
var target = parts[0];
|
||||||
var eventName = parts[1];
|
var eventName = parts[1];
|
||||||
targetEvents.push(new BoundEventAst(eventName, target,
|
var ast = this._parseAction(expression, sourceSpan);
|
||||||
this._parseAction(expression, sourceSpan), sourceSpan));
|
targetMatchableAttrs.push([name, ast.source]);
|
||||||
|
targetEvents.push(new BoundEventAst(eventName, target, ast, sourceSpan));
|
||||||
// Don't detect directives for event names for now,
|
// Don't detect directives for event names for now,
|
||||||
// so don't add the event name to the matchableAttrs
|
// so don't add the event name to the matchableAttrs
|
||||||
}
|
}
|
||||||
|
@ -327,6 +327,15 @@ export function main() {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should locate directives in event bindings', () => {
|
||||||
|
var dirA = CompileDirectiveMetadata.create(
|
||||||
|
{selector: '[a]', type: new CompileTypeMetadata({name: 'DirB'})});
|
||||||
|
|
||||||
|
expect(humanizeTplAst(parse('<div (a)="b">', [dirA])))
|
||||||
|
.toEqual(
|
||||||
|
[[ElementAst, 'div'], [BoundEventAst, 'a', null, 'b'], [DirectiveAst, dirA]]);
|
||||||
|
});
|
||||||
|
|
||||||
it('should parse directive host properties', () => {
|
it('should parse directive host properties', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
|
@ -448,6 +448,21 @@ function declareTests() {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should support directives where a selector matches event binding',
|
||||||
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
|
tcb.overrideView(
|
||||||
|
MyComp,
|
||||||
|
new ViewMetadata(
|
||||||
|
{template: '<p (customEvent)="doNothing()"></p>', directives: [EventDir]}))
|
||||||
|
|
||||||
|
.createAsync(MyComp)
|
||||||
|
.then((fixture) => {
|
||||||
|
var tc = fixture.debugElement.children[0];
|
||||||
|
expect(tc.inject(EventDir)).not.toBe(null);
|
||||||
|
async.done();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should read directives metadata from their binding token',
|
it('should read directives metadata from their binding token',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new ViewMetadata({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
@ -2133,6 +2148,13 @@ class IdDir {
|
|||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Directive({selector: '[customEvent]'})
|
||||||
|
@Injectable()
|
||||||
|
class EventDir {
|
||||||
|
@Output() customEvent = new EventEmitter();
|
||||||
|
doSomething() {}
|
||||||
|
}
|
||||||
|
|
||||||
@Directive({selector: '[static]'})
|
@Directive({selector: '[static]'})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class NeedsAttribute {
|
class NeedsAttribute {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user