Side navigation
#4275 closed enhancement (invalid)
Opened March 02, 2009 12:40AM UTC
Closed October 29, 2010 05:10PM UTC
Annotate selectors with "!" to mean "must match"
Reported by: | skrul | Owned by: | john |
---|---|---|---|
Priority: | low | Milestone: | 1.4 |
Component: | selector | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
A suggestion from a new jQuery user: Several times I've run into problems where my selector expression was not matching due to a bug, but it was not obvious since it is perfectly valid to traverse and manipulate an empty jQuery object.
So I propose adding a syntax to the selector expression that means "if this does not match, throw an exception." I think the "!" symbol is appropriate since it reminds me of CSS's "!important".
For example, $("#myid!") would throw an exception if #myid was not found.
Thoughts?
Attachments (0)
Change History (4)
Changed March 02, 2009 01:20AM UTC by comment:1
Changed March 08, 2009 10:03AM UTC by comment:2
I don't like the idea of using !, a ! reminds me far to much of not.
$('#foo!.foo');
Changed August 09, 2009 01:18AM UTC by comment:3
component: | unfilled → selector |
---|---|
owner: | → john |
priority: | major → trivial |
Changed October 29, 2010 05:10PM UTC by comment:4
priority: | trivial → low |
---|---|
resolution: | → invalid |
status: | new → closed |
! is reserved for representing "not"
You could also accomplish this with a plugin: