#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: |
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 (4)
comment:1 Changed 11 years ago by
Component: | unfiled → selector |
---|---|
Keywords: | needsdocs added |
Priority: | undecided → low |
Status: | new → open |
comment:3 Changed 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
Needs docs. Closing bug.
comment:4 Changed 10 years ago by
Keywords: | needsdocs removed |
---|
Documentation in Sizzle seems clear after the 1.8-era changes: https://github.com/jquery/sizzle/wiki/Sizzle-Documentation
I think we should update the documentation to make it clear that a boolean is necessary.