-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(tabs): ie10 MutationObserver issue #9397
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
observer.observe(element[0], config); | ||
disconnect = observer.disconnect.bind(observer); | ||
} else { | ||
element.on('DOMSubtreeModified', mutationCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@j3ski I haven't tried this out yet, but I believe that DOMSubtreeModified
is deprecated and fires very often. It might be a good idea to see if this can either be switched to an Angular watcher that "only" fires once per digest, or look into debouncing the callback (You can use the $mdUtil.debounce
method).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crisbeto Yes, DOMSubtreeModified
is deprecated, but this is a fix for browsers which don't yet support MutationObserver
. I re-implemented the functionality removed here. I don't think this can be switched to an Angular watcher, as the MutationObserver
watches for subtree modifications, not attributes, but debouncing sounds like a good idea. Initially the DOMSubtreeModified
would fire up to 9x more often than MutationObserver
in my case. Debounced it fires roughly the same amount of times as MutationObserver
(provided MO did fire), however it fires on more occasions.
observer.observe(element[0], config); | ||
disconnect = observer.disconnect.bind(observer); | ||
} else { | ||
var debounced = $mdUtil.debounce(mutationCallback, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, although could you change the debounce
signature to $mdUtil.debounce(mutationCallback, 15, null, false)
? This is because a couple of reasons:
- Passing in
false
as the last param means that it won't trigger a digest every time it gets invoked, which should help with the performance. - Bumping the time is more of a nitpick, but I feel that it's something we can get away with since it's still less than 1 frame (which is ~16ms).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Checked it, reduced the number of calls to mutationCallback by 1 in one scenario. Also the app seems to work smoother when loading the tabs, but it can be just my impression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I'll test it out manually a bit later.
Code and functionality-wise LGTM @ThomasBurleson. The commits should be squashed though. |
This reverts commit bd70022.
Check if MutationObserver is in window. If not fall back to DOMSubtreeModified event.
Closes: 9395