Side navigation
#6131 closed bug (duplicate)
Opened February 20, 2010 11:10AM UTC
Closed September 27, 2010 01:22AM UTC
Problems with "Technique from Juriy Zaytsev"
Reported by: | SleepinDevil | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.2 |
Component: | support | Version: | 1.4.1 |
Keywords: | greasemonkey Juriy Zaytsev event check code | Cc: | |
Blocked by: | Blocking: |
Description
So I noticed you guys have added some new stuff to the jQuery plugin. Including this code : Around line 960 of the developer version of code for 1.4.2
Technique from Juriy Zaytsev
http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
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;
return isSupported;
};
Its pretty good except it causes the script to stop running when I run jQuery from inside Greasemonkey.
I would seriously suggest to put the checking code inside a try{} catch(e){} to avoid the problem. I made the following change on my end and jQuery started working fine again with Greasemonkey.
I don't really care if you guys change this or not, but just decided to finally give some input to the project which hopefully will benefit someone else who finds this problem as well. Thank you.
Technique from Juriy Zaytsev & Updated by SleepinDevil
http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
var eventSupported = function( eventName ) {
var el = document.createElement("div");
eventName = "on" + eventName;
try {
var isSupported = (eventName in el);
if ( !isSupported ) {
el.setAttribute(eventName, "return;");
isSupported = typeof el[eventName] === "function";
}
el = null;
} catch(e) {
return false;
}
return isSupported;
};
This allows jquery to load, but it doesn't actually keep the desired functionality. There are a few working solutions in this thread: http://forum.jquery.com/topic/importing-jquery-1-4-1-into-greasemonkey-scripts-generates-an-error