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

发布于 2024-12-22 12:14:24 字数 642 浏览 2 评论 0原文

我刚刚注意到在最新的(金丝雀)Chrome 版本中收到了大量已弃用的警告。

event.layerX 和 event.layerY 在 WebKit 中已损坏并已弃用。它们将在不久的将来从引擎中移除。

看起来 jQuery 把事情搞砸了。

我正在使用:jquery-1.6.1.min.js

升级到最新的 jQuery 版本是否有帮助,或者尚未修复,或者是 Chrome 的错误,还是其他原因。

PS

我无法向您展示代码,因为我认为这是一个一般错误,但我怀疑当我尝试访问 jQuery 对象或 jQuery 尝试访问 LayerX / LayerY 时会抛出警告(好吧,我很确定这是考虑到的情况)错误:P)。

jQuery 可能会将这些属性复制到 jQuery 对象中。

那么……

这是怎么回事?

编辑

jQuery 1.7 已发布并修复了此问题。

了解更多信息在他们的博客上

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

勿忘初心 2024-12-29 12:14:24

这是怎么回事!?

“jQuery 可能会将这些属性复制到 jQuery 对象中。”你完全正确,所以听起来你已经知道了! :)

希望 jQuery 能够更新他们的代码以停止触及这一点,但同时 WebKit 应该知道比在事件上记录弃用警告更好(至少在我看来)。只要一个鼠标移动处理程序,您的控制台就会爆炸。 :)

这是最近的 jQuery 票证: http://bugs.jquery.com/ticket/10531

更新:如果您升级到 jQuery 1.7,此问题现已修复。

请注意,如果升级 jQuery 不能解决您的问题,则可能与使用的扩展/插件有关正如杰克在他的答案中所述。

What's going on!?

"jQuery probably copies those properties into the jQuery object." 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). One mousemove handler and your console explodes. :)

Here's a recent jQuery ticket: http://bugs.jquery.com/ticket/10531

UPDATE: This is fixed now if you upgrade to 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.

╰◇生如夏花灿烂 2024-12-29 12:14:24

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

临时修复是要在通过 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;
}());

更新

请参阅 最新表现测试找出最快的方法是删除事件道具。

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.

A君 2024-12-29 12:14:24

最短的解决方案是这样的:

$.event.props = $.event.props.join('|').replace('layerX|layerY|', '').split('|');

The shortest solution to this is this one-liner:

$.event.props = $.event.props.join('|').replace('layerX|layerY|', '').split('|');
怼怹恏 2024-12-29 12:14:24

这些消息的数量巨大(我在使用 gmail 时刚刚收到了 80000 条消息) 确实是 Chrome 中的一个错误。

您应该为Chromium 上的问题加注星标。

The enormous amount of these messages (I just got 80000 of them while using gmail) is indeed a bug in Chrome.

You should star the issue on Chromium.

一桥轻雨一伞开 2024-12-29 12:14:24

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

It can also be caused by Chrome extensions, so check them if the jQuery update doesn't work.

勿忘初心 2024-12-29 12:14:24

这是另一行修复,不替换 $.event.props 的原始实例(可能是也可能不是数组),以防万一:-)

$.each(["layerX","layerY"], function(i,v) { if((i=p.indexOf(v)) > -1) $.fn.splice.call($.event.props,i,1) })

Here is another one line fix, without replacing the original instance of $.event.props (which may or may not be an array), just in case :-)

$.each(["layerX","layerY"], function(i,v) { if((i=p.indexOf(v)) > -1) $.fn.splice.call($.event.props,i,1) })
萌逼全场 2024-12-29 12:14:24

我在调用任何事件后使用了这个:

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

这对我有用,自从我在我的代码上做了这个补丁以来,我没有任何警告消息。

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.

青芜 2024-12-29 12:14:24

除了其他答案中列出的配置问题外,您自己的代码中的一个简单错误也可能会触发此错误:忘记 jQuery ID 选择器中的“#”。

我的代码看起来像

$('datenotset_2341').click(function(){
 ....etc....
});

(遗漏了“datenotset”前面的#)

并且(显然)无法工作,它在 Chrome 中触发了此错误消息。

As well as the configuration issues listed in the other answers, this error can be triggered by a simple error in your own code: forgetting the '#' in from of a jQuery ID selector.

I had code looking like

$('datenotset_2341').click(function(){
 ....etc....
});

(missing out the # in front of the "datenotset")

As well as (obviously) failing to work, it triggered this error message in Chrome.

千仐 2024-12-29 12:14:24

我在自己的代码中遇到了这个问题。事实证明,作为我正在使用的调试/检查工具的一部分,我正在迭代事件对象的所有属性。在这个特定的实例中,我使用 jQuery 的 $.extend 来克隆对象以供以后检查,但我相信各种工具包中的任何标准迭代技术也会触发警告。

我在这里提到它是因为我最初的想法是简单地在代码库中搜索 LayerX 或 LayerY 的实例,但没有帮助 - 该属性是通用引用的,而不是按名称引用的。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文