Onclick = xxx: What is the principle of binding events in the assignment format? -

Source: Internet
Author: User
0 reply content: reasonable guess: when assigning an internal operation to onclick, remove the original one and add the new one. Pass
This is not necessarily the result of different browsers.
The underlying code is definitely not Javascript

I only went to the machine and read the oldest blink code a few years ago.
EventListenerMap depends on EventListenerVector.
This is a Vector.
Typedef Vector
In this case

When onclick setting is set to vector-> find, there is no corresponding handle
Append again
When setting is performed again, find has
Remove the old one before append.
We haven't seen the (defined) replace method of Vector.

That's why (in such a browser)

Eventually, the wheel brother guessed it right. This ff is inconsistent with chrome/safari behavior (edge is not tested ). According to the current specifications (https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handlers-12 ), Blink/webkit behavior is incorrect.



Well, congratulations, the wheel guessed a wrong implementation. Js means that there are many people to guess, without looking at the source code or norms, so there is a bunch of misleading Article subscriber models, internal should be through a list to maintain the event response, therefore, each assignment to OnClick replaces the original event Delegate. You have to make changes to this problem. Do not speculate on the behavior that is not defined in the requirement document, because it may be changed one day.

This may be a list of listener and onclick, and an attribute. attribute values are naturally overwritten. Execute properties first, and then execute the listener list.

Of course there can also be others and implementations, and the performance will be different. It is wrong for you to rely on this call order. I can have all the listener concurrency and meet the requirements, but let your program get a bug. This is just to die. Don't learn the bad habits left over from ancient times. setter method, remove old ones, and add new ones ...... You know, I guess it's true to add sub-threads to the so-called main thread queue. It's the queue. When a new employee comes out, it's from the end of the team to the head of the team.

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.