aurelia / templating-binding

An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.
MIT License
32 stars 26 forks source link

Delegate not working on DOM event #76

Closed JeroenVinke closed 8 years ago

JeroenVinke commented 8 years ago

When raising a DOM event like this:

import {inject} from 'aurelia-framework';

@inject(Element)
export class Foo {

  constructor(element) {
    this.element = element;
  }

  attached(){
    let event = new CustomEvent('test', { 'detail': {a: 'b'}});
    this.element.dispatchEvent(event);
  }
}

it can't be registered to with a delegate it seems:

  <foo test.delegate="thisDoesNotGetCalled()"></foo>

plunker: http://plnkr.co/edit/xiu4Cp8DxY7Wqjtki9LG?p=preview

Is this expected?

JeroenVinke commented 8 years ago

Trigger is working fine by the way, just wonder if delegate should work also

EisenbergEffect commented 8 years ago

You will need to specify that your custom event bubbles.

EisenbergEffect commented 8 years ago

Add bubbles: true to your options that you are passing to the CustomEvent ctor.

JeroenVinke commented 8 years ago

Ah, yes, having it bubble fixed the problem. :+1: