diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-12-22 18:00:00 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-12-22 18:00:00 +0300 |
commit | 0b5e8dba05b59f218dfdf8d226076bf912f41ff2 (patch) | |
tree | dc3d1eb3a150253c6dbe9d2d8a3be8e4827c86c5 /src | |
parent | fd5858f5423968aed8329f2cc0e5e590a7e05621 (diff) | |
download | jquery-0b5e8dba05b59f218dfdf8d226076bf912f41ff2.tar.gz jquery-0b5e8dba05b59f218dfdf8d226076bf912f41ff2.zip |
Revert "Core: Remove deprecated context and selector properties"
This reverts commit e2ec5da2a7f1b3de1f9dc7e2c01f27cd23714e60.
Diffstat (limited to 'src')
-rw-r--r-- | src/core.js | 4 | ||||
-rw-r--r-- | src/core/init.js | 12 | ||||
-rw-r--r-- | src/traversing/findFilter.js | 5 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/core.js b/src/core.js index 46c69b6c1..60d5cf221 100644 --- a/src/core.js +++ b/src/core.js @@ -43,6 +43,9 @@ jQuery.fn = jQuery.prototype = { constructor: jQuery, + // Start with an empty selector + selector: "", + // The default length of a jQuery object is 0 length: 0, @@ -71,6 +74,7 @@ jQuery.fn = jQuery.prototype = { // Add the old object onto the stack (as a reference) ret.prevObject = this; + ret.context = this.context; // Return the newly-formed element set return ret; diff --git a/src/core/init.js b/src/core/init.js index 0c4ca4552..425c1954a 100644 --- a/src/core/init.js +++ b/src/core/init.js @@ -78,9 +78,12 @@ var rootjQuery, if ( elem ) { // Inject the element directly into the jQuery object - this[ 0 ] = elem; this.length = 1; + this[0] = elem; } + + this.context = document; + this.selector = selector; return this; } @@ -96,7 +99,7 @@ var rootjQuery, // HANDLE: $(DOMElement) } else if ( selector.nodeType ) { - this[ 0 ] = selector; + this.context = this[0] = selector; this.length = 1; return this; @@ -110,6 +113,11 @@ var rootjQuery, selector( jQuery ); } + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + return jQuery.makeArray( selector, this ); }; diff --git a/src/traversing/findFilter.js b/src/traversing/findFilter.js index fcb763034..57047e0c1 100644 --- a/src/traversing/findFilter.js +++ b/src/traversing/findFilter.js @@ -72,7 +72,10 @@ jQuery.fn.extend( { 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 ) { return this.pushStack( winnow( this, selector || [], false ) ); |