Skip to main content

Bug Tracker

Side navigation

#5772 closed bug (fixed)

Opened January 08, 2010 10:53AM UTC

Closed July 28, 2010 03:08AM UTC

$() is jQuery but nut $(document) any more?

Reported by: Jessige Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.4a2
Keywords: document Cc:
Blocked by: Blocking:
Description

The line 37~38 of jquery-1.3.2.js:

[code]

// Make sure that a selection was provided

selector = selector || document;

/code

It means that $() is equal to $(document), that is very helpful. But when I updated the JQuery lib form 1.3.2 to 1.4a2, my application could not work any more.

The line 70~73 of jquery-1.4a2.js:

[code]

// Handle $(""), $(null), or $(undefined)

if ( !selector ) {

return this;

}

/code

Then what is $(), an empty jQuery object?

Maybe it will be better if:

[code]

if ( selector === undefined ) {

selector = document;

}

else if ( !selector ) {

return this;

}

/code

BTW, some spaces are lost between ")" and "{", and some ";" are lost after "}" etc.

Attachments (0)
Change History (4)

Changed January 08, 2010 10:56AM UTC by Jessige comment:1

I always use $() like this

$().keypress(function(event) {

do something here

});

Changed January 08, 2010 02:22PM UTC by dmethvin comment:2

Correct,

$()
is now an empty jQuery set in 1.4. The release notes will call it out so people can change their code before upgrading. I think it's the natural interpretation but agree it's a breaking change. Create a thread in jQuery-dev if you feel like it's too breaking. :)

http://groups.google.com/group/jquery-dev/topics

Changed January 11, 2010 03:19AM UTC by Jessige comment:3

Allll right, I do not know witch is better, but I like $() === $(document) still. :)

Changed July 28, 2010 03:08AM UTC by dmethvin comment:4

resolution: → fixed
status: newclosed