Skip to content

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

Closed
@westonpace

Description

@westonpace

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions