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

Commit

Permalink
fix(mdTooltip): Tooltip inside subheader causes Firefox hang.
Browse files Browse the repository at this point in the history
When a `<md-tooltip>` was placed inside the `<md-subheader>`,
an infinite loop was being hit (only in Firefox) which was
causing the browser to hang.

The infinite loop was caused by the tooltip's
`getParentWithPointerEvents()` method which travels up the
DOM looking for a parent who has pointer events. In Firefox,
the `element.parent()` can apparently return an empty jqLite
object that is not null, but whose length is 0. In this case,
calling `parent.parent()` again will return the same object.

Add a check to the tooltip's loop to ensure that `parent.length`
is never 0.

Fixes #4777.
  • Loading branch information
topherfangio committed Sep 23, 2015
1 parent bc4100a commit 82ff4ab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
*/
function getParentWithPointerEvents () {
var parent = element.parent();
while (parent && hasComputedStyleValue('pointer-events','none', parent[0])) {

// jqLite might return a non-null, but still empty, parent; so check for parent and length
while (parent && parent.length && hasComputedStyleValue('pointer-events','none', parent[0])) {
parent = parent.parent();
}

return parent;
}

Expand Down

0 comments on commit 82ff4ab

Please sign in to comment.