Bug Tracker

Ticket #6131 (closed bug: duplicate)

Opened 5 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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;

};

Change History

comment:1 Changed 4 years ago by cz

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

comment:2 Changed 4 years ago by dmethvin

  • Component changed from unfiled to support

comment:3 Changed 4 years ago by dmethvin

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to duplicate

Dup of #5833, see the discussion there.

Note: See TracTickets for help on using tickets.