mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Revert "Core: Remove deprecated context and selector properties"
This reverts commit 0ea8c32863
.
This commit is contained in:
parent
7a78019751
commit
c7e372b9fd
@ -42,6 +42,9 @@ jQuery.fn = jQuery.prototype = {
|
|||||||
|
|
||||||
constructor: jQuery,
|
constructor: jQuery,
|
||||||
|
|
||||||
|
// Start with an empty selector
|
||||||
|
selector: "",
|
||||||
|
|
||||||
// The default length of a jQuery object is 0
|
// The default length of a jQuery object is 0
|
||||||
length: 0,
|
length: 0,
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ jQuery.fn = jQuery.prototype = {
|
|||||||
|
|
||||||
// Add the old object onto the stack (as a reference)
|
// Add the old object onto the stack (as a reference)
|
||||||
ret.prevObject = this;
|
ret.prevObject = this;
|
||||||
|
ret.context = this.context;
|
||||||
|
|
||||||
// Return the newly-formed element set
|
// Return the newly-formed element set
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -79,9 +79,12 @@ var rootjQuery,
|
|||||||
if ( elem ) {
|
if ( elem ) {
|
||||||
|
|
||||||
// Inject the element directly into the jQuery object
|
// Inject the element directly into the jQuery object
|
||||||
this[ 0 ] = elem;
|
|
||||||
this.length = 1;
|
this.length = 1;
|
||||||
|
this[0] = elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.context = document;
|
||||||
|
this.selector = selector;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +100,7 @@ var rootjQuery,
|
|||||||
|
|
||||||
// HANDLE: $(DOMElement)
|
// HANDLE: $(DOMElement)
|
||||||
} else if ( selector.nodeType ) {
|
} else if ( selector.nodeType ) {
|
||||||
this[ 0 ] = selector;
|
this.context = this[0] = selector;
|
||||||
this.length = 1;
|
this.length = 1;
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
@ -111,6 +114,11 @@ var rootjQuery,
|
|||||||
selector( jQuery );
|
selector( jQuery );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( selector.selector !== undefined ) {
|
||||||
|
this.selector = selector.selector;
|
||||||
|
this.context = selector.context;
|
||||||
|
}
|
||||||
|
|
||||||
return jQuery.makeArray( selector, this );
|
return jQuery.makeArray( selector, this );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,7 +72,10 @@ jQuery.fn.extend( {
|
|||||||
jQuery.find( selector, self[ i ], ret );
|
jQuery.find( selector, self[ i ], ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret );
|
// Needed because $( selector, context ) becomes $( context ).find( selector )
|
||||||
|
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
|
||||||
|
ret.selector = this.selector ? this.selector + " " + selector : selector;
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
filter: function( selector ) {
|
filter: function( selector ) {
|
||||||
return this.pushStack( winnow( this, selector || [], false ) );
|
return this.pushStack( winnow( this, selector || [], false ) );
|
||||||
|
@ -53,10 +53,10 @@ QUnit.test( "jQuery()", function( assert ) {
|
|||||||
|
|
||||||
// Basic constructor's behavior
|
// Basic constructor's behavior
|
||||||
assert.equal( jQuery().length, 0, "jQuery() === jQuery([])" );
|
assert.equal( jQuery().length, 0, "jQuery() === jQuery([])" );
|
||||||
assert.equal( jQuery( undefined ).length, 0, "jQuery(undefined) === jQuery([])" );
|
assert.equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" );
|
||||||
assert.equal( jQuery( null ).length, 0, "jQuery(null) === jQuery([])" );
|
assert.equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" );
|
||||||
assert.equal( jQuery( "" ).length, 0, "jQuery('') === jQuery([])" );
|
assert.equal( jQuery("").length, 0, "jQuery('') === jQuery([])" );
|
||||||
assert.deepEqual( jQuery( obj ).get(), obj.get(), "jQuery(jQueryObj) == jQueryObj" );
|
assert.equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
|
||||||
|
|
||||||
// Invalid #id goes to Sizzle which will throw an error (gh-1682)
|
// Invalid #id goes to Sizzle which will throw an error (gh-1682)
|
||||||
try {
|
try {
|
||||||
@ -166,6 +166,7 @@ QUnit.test( "globalEval", function( assert ) {
|
|||||||
assert.equal( window.globalEvalTest, 3, "Test context (this) is the window object" );
|
assert.equal( window.globalEvalTest, 3, "Test context (this) is the window object" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
QUnit.test( "globalEval with 'use strict'", function( assert ) {
|
QUnit.test( "globalEval with 'use strict'", function( assert ) {
|
||||||
assert.expect( 1 );
|
assert.expect( 1 );
|
||||||
Globals.register( "strictEvalTest" );
|
Globals.register( "strictEvalTest" );
|
||||||
|
@ -496,10 +496,10 @@ testIframe( "offset/body", "body", function( $, window, document, assert ) {
|
|||||||
QUnit.test( "chaining", function( assert ) {
|
QUnit.test( "chaining", function( assert ) {
|
||||||
assert.expect( 3 );
|
assert.expect( 3 );
|
||||||
var coords = { "top": 1, "left": 1 };
|
var coords = { "top": 1, "left": 1 };
|
||||||
assert.equal( jQuery( "#absolute-1" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
|
assert.equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
|
||||||
assert.equal( jQuery( "#non-existent" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
|
assert.equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
|
||||||
assert.equal( jQuery( "#absolute-1" ).offset( undefined ).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
|
assert.equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
|
||||||
} );
|
});
|
||||||
|
|
||||||
QUnit.test( "offsetParent", function( assert ) {
|
QUnit.test( "offsetParent", function( assert ) {
|
||||||
assert.expect( 13 );
|
assert.expect( 13 );
|
||||||
|
Loading…
Reference in New Issue
Block a user