Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#13994 closed bug (notabug)

.on(events, ...) syntax is not logical

Reported by: WanderingZombie Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.1
Keywords: Cc:
Blocked by: Blocking:

Description

Documentation states "One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".".

This is inconsistent with other methods of selecting items, e.g.

$('div p')

selects a <p> descendants of a <div> whereas

$('div,p')

selects all <p> and all <div>. So comma = or, space = and.

The events parameter of .on() treats comma = ???, space = or.

If the events parameter of .on() used comma to delimit events, e.g.

$(something).on('change,keyup', .....

this would be a more consistent and logical way of specifying which events rather than the existing method of using space as a delimiter.

Change History (2)

comment:1 Changed 7 years ago by timmywil

Resolution: notabug
Status: newclosed

It's not or. It is and. Also, descendent selectors are not and or or, but if you and the ors or or the ands, then you have to and the ands or or the ors, and if you throw in but, it's all over the place.

Space-separated lists are common in js and are not related to selectors.

comment:2 Changed 7 years ago by dmethvin

What timmywil said. Adding that we'd still need to allow spaces, so basically we've just confused things further. And until recently there was no rule that custom event names could not contain a comma.

Note: See TracTickets for help on using tickets.