[Interview unanswered questions on 2]ios to body binding Click event Bug

Source: Internet
Author: User

The interview was asked on the iOS bug, I mentioned the binding click event Bug, but did not tell the problem very clearly, here to clean up the idea.

This bug is only available on iOS, including Ihone,ipad, because the iOS browser uses the Safari kernel, so the iOS browser is all shot.

  Bug Description

When an event delegate is made, if an element event that does not exist in the DOM is delegated directly to the body, the event delegate is invalidated, and the result is not bubbling to the body or captured by the body until the event responds to the body child element. However, if the event is in the DOM element itself, the bug is not triggered. In other words, only non-standard events of the element (such as the Click event to DIV) will trigger this bug.

  1. How to avoid a bug trigger: Do not delegate to the body node, delegate to any of the specified parent elements, or use an element that is native to the event, such as using the Click event Trigger to wrap a layer with a tag.

  2. Using the touch event instead of click, if it is a pop-up layer will be a bit of a problem exists.
  3. How patching has been triggered: Safari's parsing of events is very special, if an event has been responded to, it will always bubble (capture) to the root node, so for the case of a large-scale trigger, it is just a matter of binding an empty event on all child elements of the body element, such as:

    ("Body > *"). On ("click", Function () {};);

    may have some impact on performance, but easy to use, everyone weigh it ~ ~ ~

  

[Interview unanswered questions on 2]ios to body binding Click event Bug

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.