-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Remove all the onFoo() stub methods in widgets, or perhaps put them in doc comments so that the doc parser still picks them up.
Simplify _WidgetBase.on() to just delegate to listening for specified event on this.domNode. Code is already there, so it's just a question of removing _onMap() and the code that calls it.
Make all widgets call _WidgetBase.emit() whenever an event occurs, rather than calling the stub function directly.
For native events, like clicking a button, widgets don't need to do anything, except perhaps stop the event if the widget is disabled.
Finally, similar to how _Widget works with this._toConnect (in constructor() and postCreate(), make way so events specified to widget constructors (ex: new Button({onClick: ...}) get mapped to _WidgetBase.on() calls.
Open issues:
- Do we need to make exceptions for functions that should be directly assigned to the this, rather than using on()? Doug is always big on onClick() returning a true/false value that can stop event propagation. Maybe there are other cases too.
- Also might be nice for backwards-compatibility to keep the code in _WidgetBase.on() that sets up advice on a stub function if it exists, rather than listening for events on the DOMNode. Since that's still considered the standard way for widgets to emit events.