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

Add method for triggering events #7

Open
treshugart opened this issue Jan 15, 2017 · 2 comments
Open

Add method for triggering events #7

treshugart opened this issue Jan 15, 2017 · 2 comments

Comments

@treshugart
Copy link
Member

This should trigger an event in the same manner skate does. This should probably be called something like emit(), trigger() or dispatch() instead of simulate(), because it's not really "simulating" an event.

// Should be able to pass a string and it will emit an Event or fallback go CustomEvent
mount(<something />).emit('my-event', options);

// Should be able to emit a user-provided event instance, too.
mount(<something />).emit(new MouseEvent());
@elmariofredo
Copy link

Well it depends on how it will work, if there will be more logic than current skatejs/emit it's more like simulation than raw emit/dispatch

For instance according to my findings input event has composed flag set to true but change event has it set to false. So if we want to remove confusion and simply allow developer to call emit('input') and set proper composed flag it would be more of simulation than pure emit. Maybe this is rare case and rest of the events will be straightforward, so then it might be good idea to keep with simple emit and leave it up to documentation.

Quite frankly I couldn't even find where composed flag is in spec for input event ¯_(ツ)_/¯

@Hotell
Copy link
Contributor

Hotell commented Jan 20, 2017

Quite frankly I couldn't even find where composed flag is in spec for input event ¯_(ツ)_/¯

Indeed it is in docs. that property is on base Event interface which InputEvent extends
https://developer.mozilla.org/en-US/docs/Web/API/Event/composed

and of course complete default type definitions can be found here for InputEvent:
https://w3c.github.io/uievents/#event-type-input

all Events which extend from base Event have composed:false https://dom.spec.whatwg.org/#interface-event only if they are overridden (all events which inherit from UIEvent), like in input case, the composed is changed.

Also here is very nice summary(although old v0 spec) which events are not propagated ( composed ):

https://www.html5rocks.com/en/tutorials/webcomponents/shadowdom-301/#toc-events-stopped

Hopefully things are now clearer in terms of compose within events

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants