jQuery.on() selector should only apply to descendants of the element
|Reported by:||contact@…||Owned by:|
The $.on() method accepts a CSS selector parameter in order to setup delegated event handlers.
According to the documentation, this selector only applies to descendants of the element :
A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element.
The current implementation when the event is triggered via jQuery.event.dispatch is to call $.is() in order to match the event.target and its parents. The issue with $.is() is that it will not only test for descendants, but also for parents of the element. Considering the documentation, I think this is unintuitive.
Below an example of the issue : JSBin link : http://jsbin.com/ocijif/1/embed?live
Change History (10)
comment:2 Changed 3 years ago by gibson042
- Component changed from unfiled to event
- Resolution set to wontfix
- Status changed from new to closed
comment:5 follow-up: ↓ 7 Changed 3 years ago by dmethvin
- Cc timmywil added
- Milestone None deleted
- Priority changed from undecided to high
- Resolution wontfix deleted
- Status changed from closed to reopened
comment:8 Changed 3 years ago by dmethvin
- Milestone set to 1.8.1
- Priority changed from high to blocker