WebKit issues with event.layerX and event.layerY

2019-01-03 04:25发布

I just noticed that I get tons of deprecated warnings in the latest (canary) build of Chrome.

event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.

Looks like jQuery is screwing thing up.

I'm using: jquery-1.6.1.min.js.

Would it help to upgrade to the latest jQuery version or isn't it fixed yet or is it a Chrome bug or is it something else.

PS

I cannot show you code because I think it's a general error, but I suspect the warnings get thrown when I try to access a jQuery object or when jQuery tries to access the layerX / layerY (well I'm pretty sure that's the case considering the error :P).

jQuery probably copies those properties into the jQuery object.

So...

What's going on?

EDIT

jQuery 1.7 is out and fixes this issue.

Read more at their blog, here.

9条回答
乱世女痞
2楼-- · 2019-01-03 04:41

http://jsperf.com/removing-event-props/2

The temporary fix is to run this code before you do any event binding via jQuery:

(function(){
    // remove layerX and layerY
    var all = $.event.props,
        len = all.length,
        res = [];
    while (len--) {
      var el = all[len];
      if (el != 'layerX' && el != 'layerY') res.push(el);
    }
    $.event.props = res;
}());

UPDATE

See the latest performance tests to find out what the fastest way is to remove the event props.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-01-03 04:49

The shortest solution to this is this one-liner:

$.event.props = $.event.props.join('|').replace('layerX|layerY|', '').split('|');
查看更多
狗以群分
4楼-- · 2019-01-03 04:53

I've used this after calling any event:

$.event.props.splice($.event.props.indexOf("layerY"),1);
$.event.props.splice($.event.props.indexOf("layerX"),1);

That worked for me, I have no warning messages since I've made this patch on my code.

查看更多
登录 后发表回答