Skip to main content

Bug Tracker

Side navigation

#11246 closed bug (wontfix)

Opened January 27, 2012 01:10PM UTC

Closed July 03, 2012 02:32AM UTC

Last modified August 16, 2012 02:36PM UTC

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:
Description

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/

Attachments (0)
Change History (4)

Changed January 27, 2012 03:21PM UTC by timmywil comment:1

component: unfiledselector
keywords: → needsdocs
priority: undecidedlow
status: newopen

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

Changed January 27, 2012 03:49PM UTC by JAAulde comment:2

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

Changed July 03, 2012 02:32AM UTC by timmywil comment:3

resolution: → wontfix
status: openclosed

Needs docs. Closing bug.

Changed August 16, 2012 02:36PM UTC by dmethvin comment:4

keywords: needsdocs

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