Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

fix inline event handler issue #525 #540#541

Merged
mhevery merged 5 commits intoangular:masterfrom
JiaLiPassion:issue-525
Dec 18, 2016
Merged

fix inline event handler issue #525 #540#541
mhevery merged 5 commits intoangular:masterfrom
JiaLiPassion:issue-525

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Collaborator

@JiaLiPassion JiaLiPassion commented Dec 13, 2016

fix #525 and #540, inline event handler will not be patched with zone. And when you want to get the inline event handler will return null.

<button id="btn1" onclick="func()">ok</button>

The func will not be patched, and if you access document.getElementById('btn1').onclick will return null.

The PR will not totally fixed the issue, if you don't access the elem.onclick for example, still no patch(but not null, you will get the original native version handler). you should add the following code to patch if you want to handle inline event handler

          var all = document.getElementsByTagName("*");

          for (var i=0, max=all.length; i < max; i++) {
           var elem = all[i];
           for (var j = 0; j < eventNames.length; j ++) {
             var attr = eventNames[j];
             var attrValue = elem['on' + attr];
           }
          }

@JiaLiPassion
Copy link
Copy Markdown
Collaborator Author

If zone.js don't want to support inline event handler attribute, this PR is not necessary, inline event handler is not a good solution anyway.

@mhevery mhevery merged commit 20b5a5d into angular:master Dec 18, 2016
@JiaLiPassion JiaLiPassion deleted the issue-525 branch December 19, 2016 00:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zone.js patch DOM on-event handler will failed with inline event handler.

3 participants