Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#11246 closed bug (wontfix)

Custom selectors pass check when returning undefined

Reported by: JAAulde Owned by:
Priority: low Milestone: None
Component: selector Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:


When writing a custom selector and giving it a function as the rule, returning truthy from the function passes the check, and returning falsy fails. That is the case unless the function returns undefined. Although undefined is falsy, the check is considered to have passed.

While I think any such function should return a strict BOOL, there is no official documentation (that I can find, anyway) on how a custom selector should be written and what these functions should be returning.

This stems from a trouble ticket opened to TinyMCE ( http://www.tinymce.com/develop/bugtracker_view.php?id=4975 ). I believe they need to correct their function to return BOOL, but I felt this should be brought to the attention of the jQuery core team as it could be happening in many other places.

See this fiddle: http://jsfiddle.net/Pw43h/

Change History (4)

comment:1 Changed 11 years ago by timmywil

Component: unfiledselector
Keywords: needsdocs added
Priority: undecidedlow
Status: newopen

I think we should update the documentation to make it clear that a boolean is necessary.

comment:2 Changed 11 years ago by JAAulde

I think that's a perfectly valid plan of action.

comment:3 Changed 11 years ago by timmywil

Resolution: wontfix
Status: openclosed

Needs docs. Closing bug.

comment:4 Changed 10 years ago by dmethvin

Keywords: needsdocs removed

Documentation in Sizzle seems clear after the 1.8-era changes: https://github.com/jquery/sizzle/wiki/Sizzle-Documentation

Note: See TracTickets for help on using tickets.