Skip to main content

Bug Tracker

Side navigation

Ticket #4036: blank.diff


File blank.diff, 0.7 KB (added by dimi, February 01, 2009 08:12AM UTC)

Patch implementing the .blank() function.

--- jquery-1.3.1.js	2009-02-01 02:54:55.000000000 -0500
+++ jquery-1.3.1-a.js	2009-02-01 02:57:30.000000000 -0500
@@ -636,9 +636,7 @@
 
 	// Evalulates a script in a global context
 	globalEval: function( data ) {
-		data = jQuery.trim( data );
-
-		if ( data ) {
+		if ( !jQuery.blank( data ) ) {
 			// Inspired by code by Andrea Giammarchi
 			// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
 			var head = document.getElementsByTagName("head")[0] || document.documentElement,
@@ -1050,6 +1048,10 @@
 		return elem[ name ];
 	},
 
+	blank: function( text ) {
+		return !text ||  /^\s*$/.test(text);
+	},
+
 	trim: function( text ) {
 		return (text || "").replace( /^\s+|\s+$/g, "" );
 	},

Download in other formats:

Original Format