Skip to main content

Bug Tracker

Side navigation

Ticket #1807: jQuery.patch.txt


File jQuery.patch.txt, 1.1 KB (added by gyphie, October 15, 2007 06:29PM UTC)

Unified diff for patching the bug.

--- C:/mydocs/projects/javascript libraries/jquery/jquery-1.2.1.js	Fri Oct 12 14:48:30 2007
+++ C:/mydocs/projects/javascript libraries/jquery/jquery-1.2.1.jwr1.js	Fri Oct 12 16:20:18 2007
@@ -15,6 +15,9 @@
 	var _jQuery = jQuery;
 
 var jQuery = window.jQuery = function(selector, context) {
+    if (!arguments.length) selector = document; // Make sure $() returns [ document ]
+    context = context || document;  // If no context is specified then default to document
+
 	// If the context is a namespace object, return a new object
 	return this instanceof jQuery ?
 		this.init(selector, context) :
@@ -32,11 +35,12 @@
 
 jQuery.fn = jQuery.prototype = {
 	init: function(selector, context) {
-		// Make sure that a selection was provided
-		selector = selector || document;
-
+        // Undefined selectors should return an empty set
+		if ( typeof selector === "undefined" ) {
+		    selector = [];
+		}
 		// Handle HTML strings
-		if ( typeof selector  == "string" ) {
+		else if ( typeof selector  == "string" ) {
 			var m = quickExpr.exec(selector);
 			if ( m && (m[1] || !context) ) {
 				// HANDLE: $(html) -> $(array)

Download in other formats:

Original Format