Created
July 25, 2012 01:42
-
-
Save johnpena/3173880 to your computer and use it in GitHub Desktop.
fix for pushstack issues in jquery+chrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| jQuery.fn.pushStack = function( elems, name, selector ) { | |
| // Build a new jQuery matched element set | |
| var ret = this.constructor(); | |
| // temporary workaround for chrome issue #125148 | |
| // http://code.google.com/p/chromium/issues/detail?id=125148 | |
| if (!(ret instanceof jQuery.fn.init)) { | |
| console.log("applying pushStack fix"); | |
| ret = new jQuery.fn.init(); | |
| } | |
| if ( jQuery.isArray( elems ) ) { | |
| push.apply( ret, elems ); | |
| } else { | |
| jQuery.merge( ret, elems ); | |
| } | |
| // Add the old object onto the stack (as a reference) | |
| ret.prevObject = this; | |
| ret.context = this.context; | |
| if ( name === "find" ) { | |
| ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; | |
| } else if ( name ) { | |
| ret.selector = this.selector + "." + name + "(" + selector + ")"; | |
| } | |
| // Return the newly-formed element set | |
| return ret; | |
| }; | |
| }).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment