Skip to main content

Bug Tracker

Side navigation

Ticket #6603: jquery-1.4.2-gm-support.diff


File jquery-1.4.2-gm-support.diff, 1.0 KB (added by taw, May 26, 2010 09:29PM UTC)

Patch to make jQuery not die with "Component not avaialble" exception when used in Greasemonkey

--- jquery-1.4.2.js	2010-02-14 03:35:05.000000000 +0000
+++ jquery-1.4.2-gm.js	2010-05-26 22:20:50.000000000 +0100
@@ -950,18 +950,21 @@
 
 	// Technique from Juriy Zaytsev
 	// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+	// Test doesn't work in Greasemonkey due to security sandbox
 	var eventSupported = function( eventName ) { 
 		var el = document.createElement("div"); 
 		eventName = "on" + eventName; 
 
-		var isSupported = (eventName in el); 
-		if ( !isSupported ) { 
-			el.setAttribute(eventName, "return;"); 
-			isSupported = typeof el[eventName] === "function"; 
-		} 
-		el = null; 
+    try{
+  		var isSupported = (eventName in el); 
+  		if ( !isSupported ) { 
+  			el.setAttribute(eventName, "return;"); 
+  			isSupported = typeof el[eventName] === "function"; 
+  		} 
+  		el = null; 
 
-		return isSupported; 
+  		return isSupported; 
+	  } catch(Exception) {}
 	};
 	
 	jQuery.support.submitBubbles = eventSupported("submit");

Download in other formats:

Original Format