Skip to main content

Bug Tracker

Side navigation

#1955 closed enhancement (invalid)

Opened November 22, 2007 08:28AM UTC

Closed November 27, 2007 07:33PM UTC

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.

Attachments (0)
Change History (2)

Changed November 26, 2007 01:28AM UTC by davidserduke comment:1

need: ReviewTest Case

Can you give an actual example of the problem you are experiencing? Or is this a design comment?

Changed November 27, 2007 07:33PM UTC by davidserduke comment:2

priority: majorminor
resolution: → invalid
status: newclosed
type: bugenhancement

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.