Skip to content

Instantly share code, notes, and snippets.

@dcneiner
Created December 20, 2011 17:20
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcneiner/1502384 to your computer and use it in GitHub Desktop.
Save dcneiner/1502384 to your computer and use it in GitHub Desktop.
Removes the use of layerX and layerY in jQuery 1.4, 1.5, 1.6 (If you can't upgrade to jQuery 1.7 for some reason) - Even referencing these properties throws a warning in Chrome
// Add this code snippet after including jQuery
// The if statement protects you in case you forget to remove this
// once you upgrade to 1.7, or if you try to use it with jQuery 1.3
if (jQuery.event.props[17] === "layerX" ) {
jQuery.event.props.splice(17,2);
}
@mathiasbynens
Copy link

FYI, I made this jsPerf test case with some alternatives a while back: http://jsperf.com/removing-event-props

@peol
Copy link

peol commented Dec 21, 2011

Perhaps make this a bit safer with:
(function(p){p[17]==="layerX"&&p.splice(17, 2);})(window.jQuery&&jQuery.event.props||[]);

Still assumes if jQuery is defined, it'll have the .event namespace, but still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment