Skip to main content

Bug Tracker

Side navigation

Ticket #4036: blank-1.diff
File blank-1.diff, 0.7 KB (added by dimi, February 01, 2009 04:15PM UTC)

Smaller, much faster version of .blank()

--- jquery-1.3.1-orig.js	2009-02-01 10:53:19.000000000 -0500
+++ jquery-1.3.1-d.js	2009-02-01 10:53:44.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