add generic patch eventtarget method#549
Conversation
|
@JiaLiPassion please add the PR for MatchMedia support using your new patchEventTargetMethods. You can use the tests in my branch to validate. |
|
@poxrud , ok, thank you, I will make a PR with the generic method and your test code. |
|
@poxrud , I am testing the code in my branch now, the problem is that a lot of different errors occur in the test codes on IE10/IE11/Safari9/Android, I add some code to check the MediaQuery availability, but still error occurs, it will take some time for me to fix them, and I think the MediaQuery is so experimental feature, maybe at last you should call a API (zone.patchMediaQuery) from app side. I will continue to debug the test code in those env (IE/Android) |
|
Yes you need to check if MatchMedia is supported with something like: If you don't mind pasting your patching code I'd like to test it out myself as well. |
now util.ts provide a patchEventTargetMethods to patch dom addEventListener and nodejs EventEmitter addEventListener method.
becasue dom/node addEventListener has the similar signature.
It is ok for dom element and node, but in other case, for example in PR #543, if we want to patch
other eventTarget like MediaQuery , the add listener method signature is different
So if we want to patch it, we need to write another patch logic like #543, it is not effective and in the future, if we want to patch other event Target like notification API like #536, we will need another same logic, so we need a generic way to patch event target like object.
In this PR, I provide a ListenerTaskMeta creator to create related information for customize, so
to fix #543, we may call like this.