Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

md-icon + resize-observer-polyfill = Infinite loop #2642

Closed
westonpace opened this issue Jan 13, 2017 · 1 comment · Fixed by #2649
Closed

md-icon + resize-observer-polyfill = Infinite loop #2642

westonpace opened this issue Jan 13, 2017 · 1 comment · Fixed by #2649

Comments

@westonpace
Copy link
Contributor

Bug, feature request, or proposal:

I am using resize-observer-polyfill to watch for a window resizing (to update a graph drawn with d3). Under the hood it places a MutationObserver on the entire dom. If I have an md-icon in my application the application freezes.

What is the expected behavior?

The application should not freeze.

What is the current behavior?

The application freezes.

What are the steps to reproduce?

WARNING: If you are using chrome and hit run then this plunkr will eat 1 core and hang chrome.
http://plnkr.co/edit/1vgLbRbsV7D8RWvoBK8Y

What is the use-case or motivation for changing an existing behavior?

I would like to be able to use both resize-observer-polyfill and md-icon.

Which versions of Angular, Material, OS, browsers are affected?

I'd assume all.

Is there anything else we should know?

The root cause is that md-icon sets the aria-label attribute every single time ngAfterViewChecked is run. Setting this attribute is a DOM change and triggers the mutation observer. The mutation observer runs and then triggers a view check.

A simple patch to prevent modifying the DOM unless the aria label actually changed fixes the issue. I will submit a pull request soon.

westonpace added a commit to westonpace/material2 that referenced this issue Jan 14, 2017
The md-icon component now caches the aria-label value and
only actually modifies the DOM if the value is unchanged.
This prevents md-icon from modifying the DOM every iteration
of change detection.

Closed angular#2642
kara pushed a commit that referenced this issue Jan 31, 2017
@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants