Ticket #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: | ||
| Blocking: | Blocked by: |
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/
Change History
comment:1 Changed 17 months ago by timmywil
- Keywords needsdocs added
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to selector
comment:3 Changed 12 months ago by timmywil
- Status changed from open to closed
- Resolution set to wontfix
Needs docs. Closing bug.
comment:4 Changed 10 months 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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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