Skip to content

Commit e2ec5da

Browse files
committed
Core: Remove deprecated context and selector properties
Fixes jquerygh-1908 Closes jquerygh-2000 (cherry picked from commit 0ea8c32)
1 parent 26150f0 commit e2ec5da

File tree

5 files changed

+7
-65
lines changed

5 files changed

+7
-65
lines changed

src/core.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ jQuery.fn = jQuery.prototype = {
3939

4040
constructor: jQuery,
4141

42-
// Start with an empty selector
43-
selector: "",
44-
4542
// The default length of a jQuery object is 0
4643
length: 0,
4744

@@ -70,7 +67,6 @@ jQuery.fn = jQuery.prototype = {
7067

7168
// Add the old object onto the stack (as a reference)
7269
ret.prevObject = this;
73-
ret.context = this.context;
7470

7571
// Return the newly-formed element set
7672
return ret;

src/core/init.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,9 @@ var rootjQuery,
7575

7676
if ( elem ) {
7777
// Inject the element directly into the jQuery object
78-
this.length = 1;
7978
this[0] = elem;
79+
this.length = 1;
8080
}
81-
82-
this.context = document;
83-
this.selector = selector;
8481
return this;
8582
}
8683

@@ -96,7 +93,7 @@ var rootjQuery,
9693

9794
// HANDLE: $(DOMElement)
9895
} else if ( selector.nodeType ) {
99-
this.context = this[0] = selector;
96+
this[0] = selector;
10097
this.length = 1;
10198
return this;
10299

@@ -109,11 +106,6 @@ var rootjQuery,
109106
selector( jQuery );
110107
}
111108

112-
if ( selector.selector !== undefined ) {
113-
this.selector = selector.selector;
114-
this.context = selector.context;
115-
}
116-
117109
return jQuery.makeArray( selector, this );
118110
};
119111

src/traversing/findFilter.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ jQuery.fn.extend({
7272
jQuery.find( selector, self[ i ], ret );
7373
}
7474

75-
// Needed because $( selector, context ) becomes $( context ).find( selector )
76-
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
77-
ret.selector = this.selector ? this.selector + " " + selector : selector;
78-
return ret;
75+
return this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
7976
},
8077
filter: function( selector ) {
8178
return this.pushStack( winnow(this, selector || [], false) );

test/unit/core.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test("jQuery()", function() {
5757
equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" );
5858
equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" );
5959
equal( jQuery("").length, 0, "jQuery('') === jQuery([])" );
60-
equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
60+
deepEqual( jQuery(obj).get(), obj.get(), "jQuery(jQueryObj) == jQueryObj" );
6161

6262
// Invalid #id goes to Sizzle which will throw an error (gh-1682)
6363
try {
@@ -156,49 +156,6 @@ test("jQuery(selector, context)", function() {
156156
deepEqual( jQuery("div p", jQuery("#qunit-fixture")).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
157157
});
158158

159-
test( "selector state", function() {
160-
expect( 18 );
161-
162-
var test;
163-
164-
test = jQuery( undefined );
165-
equal( test.selector, "", "Empty jQuery Selector" );
166-
equal( test.context, undefined, "Empty jQuery Context" );
167-
168-
test = jQuery( document );
169-
equal( test.selector, "", "Document Selector" );
170-
equal( test.context, document, "Document Context" );
171-
172-
test = jQuery( document.body );
173-
equal( test.selector, "", "Body Selector" );
174-
equal( test.context, document.body, "Body Context" );
175-
176-
test = jQuery("#qunit-fixture");
177-
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
178-
equal( test.context, document, "#qunit-fixture Context" );
179-
180-
test = jQuery("#notfoundnono");
181-
equal( test.selector, "#notfoundnono", "#notfoundnono Selector" );
182-
equal( test.context, document, "#notfoundnono Context" );
183-
184-
test = jQuery( "#qunit-fixture", document );
185-
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
186-
equal( test.context, document, "#qunit-fixture Context" );
187-
188-
test = jQuery( "#qunit-fixture", document.body );
189-
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
190-
equal( test.context, document.body, "#qunit-fixture Context" );
191-
192-
// Test cloning
193-
test = jQuery( test );
194-
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
195-
equal( test.context, document.body, "#qunit-fixture Context" );
196-
197-
test = jQuery( document.body ).find("#qunit-fixture");
198-
equal( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" );
199-
equal( test.context, document.body, "#qunit-fixture find Context" );
200-
});
201-
202159
test( "globalEval", function() {
203160
expect( 3 );
204161
Globals.register("globalEvalTest");

test/unit/offset.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ testIframe("offset/body", "body", function( $ ) {
478478
test("chaining", function() {
479479
expect(3);
480480
var coords = { "top": 1, "left": 1 };
481-
equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
482-
equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
483-
equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
481+
equal( jQuery("#absolute-1").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
482+
equal( jQuery("#non-existent").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
483+
equal( jQuery("#absolute-1").offset(undefined).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
484484
});
485485

486486
test("offsetParent", function(){

0 commit comments

Comments
 (0)