WebKit与event.layerX和event.layerY有关的问题

本文翻译自:WebKit issues with event.layerX and event.layerY

I just noticed that I get tons of deprecated warnings in the latest (canary) build of Chrome. 我刚刚注意到,在最新版(金丝雀)的Chrome浏览器中,我收到了很多不推荐使用的警告。

event.layerX and event.layerY are broken and deprecated in WebKit. WebKit中的event.layerX和event.layerY已损坏和弃用。 They will be removed from the engine in the near future. 它们将在不久的将来从引擎中删除。

Looks like jQuery is screwing thing up. 看起来jQuery搞砸了。

I'm using: jquery-1.6.1.min.js . 我正在使用: 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. 它是否有助于升级到最新的jQuery版本,或者它是否已修复,或者是Chrome错误还是其他?

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对象或jQuery尝试访问layerX / layerY时会抛出警告(嗯,我很确定这是考虑到错误:P)。

jQuery probably copies those properties into the jQuery object. jQuery可能会将这些属性复制到jQuery对象中。

So... 所以...

What's going on? 这是怎么回事?

EDIT 编辑

jQuery 1.7 is out and fixes this issue. jQuery 1.7已经发布并解决了此问题。

Read more at their blog, here . 在这里,在他们的博客上阅读更多内容。


#1楼

参考:https://stackoom.com/question/Wpku/WebKit与event-layerX和event-layerY有关的问题


#2楼

I ran into this issue in my own code. 我在自己的代码中遇到了这个问题。 It turns out I was iterating over all properties on an event object as part of a debugging/inspection tool that I was using. 事实证明,我正在迭代事件对象的所有属性,这是我使用的调试/检查工具的一部分。 In this particular instance I was using jQuery's $.extend to clone the object for later inspection, but I believe any of the standard iteration techniques in the various toolkits would have triggered the warning as well. 在此特定实例中,我使用jQuery的$ .extend克隆对象以供以后检查,但我相信各种工具包中的任何标准迭代技术也会触发该警告。

I mention it here because my initial thought of simply searching the code base for instances of layerX or layerY didn't help - the property was being referenced generically, not by name. 我在这里提到它是因为我最初的想法只是简单地在代码库中搜索layerX或layerY实例并没有帮助-该属性是通用引用的,而不是名称。


#3楼

What's going on!? 这是怎么回事!?

"jQuery probably copies those properties into the jQuery object." “ jQuery可能会将这些属性复制到jQuery对象中。” You're exactly correct, so it sounds like you already know! 您完全正确,因此听起来您已经知道了! :) :)

Hopefully jQuery will update their code to stop touching that, but at the same time WebKit should have known better than to log a deprecation warning on an event (at least in my opinion). 希望jQuery将更新其代码以停止修改,但与此同时WebKit应该比在事件中记录弃用警告更好(至少在我看来)。 One mousemove handler and your console explodes. 一个mousemove处理程序和您的控制台爆炸。 :) :)

Here's a recent jQuery ticket: http://bugs.jquery.com/ticket/10531 这是最近的jQuery票证: http : //bugs.jquery.com/ticket/10531

UPDATE: This is fixed now if you upgrade to jQuery 1.7. 更新:如果您升级到jQuery 1.7,现在已修复。

Please note that if upgrading jQuery doesn't fix the issue for you it may have something to do with used extensions / plugins as Jake stated in his answer . 请注意,如果升级jQuery不能为您解决问题,则可能与使用的扩展名/插件有关,如Jake在其回答中所述


#4楼

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

The temporary fix is to run this code before you do any event binding via jQuery: 临时解决方法是在通过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. 查看最新的性能测试以了解最快的方法是删除事件道具。


#5楼

The enormous amount of these messages (I just got 80000 of them while using gmail) is indeed a bug in Chrome. 这些消息的数量之多(使用gmail时我刚收到80000条消息确实是Chrome中的错误。

You should star the issue on Chromium . 您应该在Chromium上加注


#6楼

它也可能是由Chrome扩展引起的,因此,请检查它们是否jQuery更新不起作用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值