- Notifications
You must be signed in to change notification settings - Fork20.6k
Core: Remove deprecated context and selector properties#2000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -73,12 +73,9 @@ var rootjQuery, | ||
if ( elem ) { | ||
// Inject the element directly into the jQuery object | ||
this[0] = elem; | ||
this.length = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We would save more bytes that way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Or just for the consistency withhttps://github.com/jquery/jquery/pull/2000/files#diff-85f162ae43172ebe26b51a4d1c5d4eddR94 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Seemed strange to set the length before the element. I pulled several of the changes from@gibson042 's older PR because they just seemed so right. 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. :) | ||
} | ||
return this; | ||
} | ||
@@ -94,7 +91,7 @@ var rootjQuery, | ||
// HANDLE: $(DOMElement) | ||
} else if ( selector.nodeType ) { | ||
this[0] = selector; | ||
this.length = 1; | ||
return this; | ||
@@ -107,11 +104,6 @@ var rootjQuery, | ||
selector( jQuery ); | ||
} | ||
return jQuery.makeArray( selector, this ); | ||
}; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -462,9 +462,9 @@ testIframe("offset/body", "body", function( $ ) { | ||
test("chaining", function() { | ||
expect(3); | ||
var coords = { "top": 1, "left": 1 }; | ||
equal( jQuery("#absolute-1").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Always wondered why this property was named "jquery", not "version" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's killing two birds with one stone: thepresence of the property identifies an object as a jQuery collection as opposed to Array/NodeList/Prototype/Zepto/etc., and the value specifies which version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
Yeah! Or "a bird in the hand is worth two in the bush" This property indeed serve for two complitly different things, but i don't think that's good, i think these should be exposed explicitly then otherwise. Besides, i'm not sure that was an original intent.
This could always be done by other means, like: functiontest(){}newtest().constructor.name// test// i.e. we could dofunctionjQuery(){}jQuery.prototype.constructor=jQuery;$().constructor.name// "jQuery" Or other countless ways to do it. Not saying we should do something about it, it might be too late, like with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yea, it's too late. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Until I looked at the old PR, I had just planned to see if the I guess There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
Isn't that frustrating? We can't improve something because people are dependent upon it.
If i would do it today, i would called it "version" and provided other ways to identify jquery object There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
The purposes aren't completely different; they're analogous to | ||
equal( jQuery("#non-existent").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" ); | ||
equal( jQuery("#absolute-1").offset(undefined).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" ); | ||
}); | ||
test("offsetParent", function(){ | ||