Skip to content

Commit 205935b

Browse files
committed
Core: Remove deprecated context and selector properties
Fixes jquerygh-1908
1 parent a3779bc commit 205935b

File tree

6 files changed

+8
-65
lines changed

6 files changed

+8
-65
lines changed

src/core.js

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

4141
constructor: jQuery,
4242

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

@@ -71,7 +68,6 @@ jQuery.fn = jQuery.prototype = {
7168

7269
// Add the old object onto the stack (as a reference)
7370
ret.prevObject = this;
74-
ret.context = this.context;
7571

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

src/core/init.js

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

7474
if ( elem ) {
7575
// Inject the element directly into the jQuery object
76-
this.length = 1;
7776
this[0] = elem;
77+
this.length = 1;
7878
}
79-
80-
this.context = document;
81-
this.selector = selector;
8279
return this;
8380
}
8481

@@ -94,7 +91,7 @@ var rootjQuery,
9491

9592
// HANDLE: $(DOMElement)
9693
} else if ( selector.nodeType ) {
97-
this.context = this[0] = selector;
94+
this[0] = selector;
9895
this.length = 1;
9996
return this;
10097

@@ -107,11 +104,6 @@ var rootjQuery,
107104
selector( jQuery );
108105
}
109106

110-
if ( selector.selector !== undefined ) {
111-
this.selector = selector.selector;
112-
this.context = selector.context;
113-
}
114-
115107
return jQuery.makeArray( selector, this );
116108
};
117109

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/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<!-- iframes will not load AMD as loading needs to be synchronous for some tests -->
2626
<!-- Also executes the function above to load tests -->
2727
<script src="jquery.js"></script>
28+
<script src="jquery-migrate.js"></script>
2829

2930
<script>
3031
// Load tests if they have not been loaded

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
@@ -462,9 +462,9 @@ testIframe("offset/body", "body", function( $ ) {
462462
test("chaining", function() {
463463
expect(3);
464464
var coords = { "top": 1, "left": 1 };
465-
equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
466-
equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
467-
equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
465+
equal( jQuery("#absolute-1").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
466+
equal( jQuery("#non-existent").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
467+
equal( jQuery("#absolute-1").offset(undefined).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
468468
});
469469

470470
test("offsetParent", function(){

0 commit comments

Comments
 (0)