Bug Tracker

Opened 13 years ago

Closed 13 years ago

#5772 closed bug (fixed)

$() 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:


The line 37~38 of jquery-1.3.2.js: [code] Make sure that a selection was provided

selector = selector


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.

Change History (4)

comment:1 Changed 13 years ago by Jessige

I always use $() like this $().keypress(function(event) {

do something here


comment:2 Changed 13 years ago by dmethvin

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. :)


comment:3 Changed 13 years ago by Jessige

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

comment:4 Changed 13 years ago by dmethvin

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.