Opened 15 years ago
Closed 15 years ago
#1955 closed enhancement (invalid)
When no element matches the selector, the plugin function should not be exist
Reported by: | bluenose | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.2.2 |
Component: | core | Version: | 1.2.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If we define a plugin, for example $.fn.example = ...
when $("#notexist").get().length == 0 the function example should not be executed. jQuery-1.1.3.js is ok for doing this. but jQuery-1.2.1 not.
Change History (2)
comment:1 Changed 15 years ago by
need: | Review → Test Case |
---|
comment:2 Changed 15 years ago by
Priority: | major → minor |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Type: | bug → enhancement |
The author seems to be suggesting that when the jquery object has no objects it should stop calling functions such that
$([]).example();
Wouldn't execute the example() code. The author also seems to suggest that 1.1.3 didn't which seems unlikely but was before my time.
I don't see any compelling reason to attempt make this change. In fact, I can imagine situations where a plugin could still want to be called even when no elements were found (like a plugin that displays how many of a certain selector are found) so I'm going to close this bug on that basis. If there is an actual test case that can display an actual problem please reopen the bug with that test case.
Can you give an actual example of the problem you are experiencing? Or is this a design comment?