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

mdTooltip: $digest already in progress when there are a number of disabled elements #8011

@Frank3K

Description

@Frank3K

In Firefox 45.0.1 on Linux I encounter the following issue when loading a page with a number of disabled md-button elements, each with its own md-tooltip.

Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.5.3/$rootScope/inprog?p0=%24digest

I have tracked down the issue to the following line 157 in tooltip.js:

      // add an mutationObserver when there is support for it
      // and the need for it in the form of viable host(parent[0])
      if (parent[0] && 'MutationObserver' in $window) {
        // use an mutationObserver to tackle #2602
        var attributeObserver = new MutationObserver(function(mutations) {
          mutations.forEach(function (mutation) {
            if (mutation.attributeName === 'disabled' && parent[0].disabled) {
              setVisible(false);
              scope.$digest(); // make sure the elements gets updated
            }
          });
        });

        attributeObserver.observe(parent[0], { attributes: true});
      }

When there are mutations for multiple elements (I enable most elements on a certain loaded event), a number of digest are executed if I read the code correctly. This is what (I think) triggers the error.

I'm no expert in $digest(), so I do not know what the best solution is. My first approach was to move the scope.$digest() outside the forEach but that did not fix the issue. Note that commenting the line altogether does remove the error, so I'm quite sure this is the offending call.

Metadata

Metadata

Assignees

Labels

P1: urgentUrgent issues that should be addressed in the next minor or patch release.resolution: can't reproduceThe team is unable to reproduce this issue with the information provided

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions