Skip to content

Commit b5cdf04

Browse files
Migration guide: mentioning native non-bubbling events
1 parent 875944c commit b5cdf04

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

docs/migration_guide.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ event.cancelBubble;
112112
event;
113113
```
114114

115+
### Non-bubbling events
116+
117+
Some native events don't actually bubble at the browser level, for historical reasons: `focus`, `blur`, `mouseenter` and `mouseleave`, but alternative bubbling versions of these events exist: `focusin`, `focusout`, `mouseover` and `mouseout`.
118+
119+
Both jQuery and Cash let you use the non-bubbling version of these events and transparently make them bubble, however there are some minor differences:
120+
121+
- In Cash if you pass `$.fn.on` the non-bubbling version of an event, and then pass `$.fn.trigger` the bubbling version of that event, the event handler registered for the non-bubbling version of that event won't be triggered, you must use event names consistently.
122+
- In jQuery depending on the circumstances the event handler registered for the non-bubbling version of an event could be triggered even when then triggering the bubbling version of that event.
123+
- In Cash as long as you use non-bubbling events with the provided event functions, like `$.fn.on` and `$.fn.trigger`, they will always be made bubble. If you instead trigger non-bubbling events manually, like by calling the `focus` method of an element, that event won't be made bubble.
124+
- In jQuery natively-triggered non-bubbling events will be made bubble too.
125+
115126
### Stopping propagation from a delegated event handler
116127

117128
In Cash when using event delegation calling `event.stopPropagation` or returning `false` stops the propagation from the target element, not the delegate element.

0 commit comments

Comments
 (0)