为什么event.bubbles对于"focusin"而言为假?和“聚焦"? [英] Why event.bubbles is false for "focusin" and "focusout"?

查看:109
本文介绍了为什么event.bubbles对于"focusin"而言为假?和“聚焦"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几分钟前,我回答了这个问题:
在jQuery中focusin/focusout与focus/blur之间有什么区别?

Couple of minutes ago, I answered the question:
What is the difference between focusin/focusout vs focus/blur in jQuery?

答案是:

简短回答:focusin   气泡,focus则不.
       focusout气泡,blur 不会.

Short answer: focusin    bubbles, focus does not.
        focusout bubbles, blur   does not.

我测试了它,这是真的,但是在尝试设置> 演示 :

I tested it, it's true, but I encountered a weird thing while trying to set up a DEMO:

$('#test').on('focusin focusout focus blur change', function(e) {
    console.log(e.type + 'event bubles? : ' + e.bubbles);
});​

focusinfocusout给我e.bubbles == false

是jQuery的错误还是我在这里遗漏了明显的内容?

Is it a bug of jQuery or am I missing the obvious here?

推荐答案

听起来像jQuery中的错误.您是否在本机支持focusinfocusout的浏览器上对此进行了测试? (例如IE?)因为如果没有,您正在测试jQuery的模拟支持标志.

Sounds like a bug in jQuery. Did you test this on a browser that supports focusin and focusout natively? (E.g., IE?) Because if not, you're testing the flag for jQuery's emulated support.

我已经删除了上面的听起来像个bug的声音",因为jQuery并没有声称要规范文档中的bubbles属性.因此,由于它不能保证它,因此不必在模拟事件上支持它. (请注意,如果我在IE7上运行您的演示,则会得到undefined,因为IE7不支持DOM3事件的bubbles属性.)仍然是 issue ,但可能不是 bug . :-)

I've crossed out the "Sounds like a bug" bit above because jQuery doesn't claim to normalize the bubbles property in the documentation. So since it doesn't guarantee it, it doesn't have to support it on emulated events. (Note that if I run your demo on IE7, I get undefined because IE7 doesn't support the DOM3 Events bubbles property.) Still an issue, but perhaps not a bug. :-)

更新:

jQuery票证上的响应:

文档没有声称要规范化event.bubbles属性.您可以在event.originalEvent中查找它,但这将是未标准化的平台所提供的任何内容.

The documentation doesn't claim to normalize the event.bubbles property. You can look for it in event.originalEvent but that will be whatever the platform provided, unnormalized.

所以我上面的猜测是正确的.这不是一个 bug ,因为他们没有声称要对其进行规范化. :-)

So my guess above was correct. It's not a bug, because they don't claim to normalize that. :-)

这篇关于为什么event.bubbles对于"focusin"而言为假?和“聚焦"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆