Opened 14 years ago
Closed 12 years ago
#4275 closed enhancement (invalid)
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?
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
I don't like the idea of using !, a ! reminds me far to much of not. $('#foo!.foo');
comment:3 Changed 13 years ago by
Component: | unfilled → selector |
---|---|
Owner: | set to john |
Priority: | major → trivial |
comment:4 Changed 12 years ago by
Priority: | trivial → low |
---|---|
Resolution: | → invalid |
Status: | new → closed |
! is reserved for representing "not"
You could also accomplish this with a plugin: