Skip to main content

Bug Tracker

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;

};

Attachments (0)
Change History (3)

Changed March 30, 2010 12:58PM UTC by cz comment:1

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

Changed June 15, 2010 12:09AM UTC by dmethvin comment:2

component: unfiledsupport

Changed September 27, 2010 01:22AM UTC by dmethvin comment:3

priority: → undecided
resolution: → duplicate
status: newclosed

Dup of #5833, see the discussion there.