Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix scroll to text node (#413)
Browse files Browse the repository at this point in the history
* Fix scroll to text node

* Address feedback
  • Loading branch information
gaearon committed Aug 19, 2016
1 parent 776a0ae commit 59508f6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions agent/Agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,18 @@ class Agent extends EventEmitter {
console.warn('unable to get the node for scrolling');
return;
}
if (node.scrollIntoViewIfNeeded) {
node.scrollIntoViewIfNeeded();
} else {
node.scrollIntoView();
var element = node.nodeType === Node.ELEMENT_NODE ?
node :
node.parentElement;
if (!element) {
console.warn('unable to get the element for scrolling');
return;
}

if (typeof element.scrollIntoViewIfNeeded === 'function') {
element.scrollIntoViewIfNeeded();
} else if (typeof element.scrollIntoView === 'function') {
element.scrollIntoView();
}
this.highlight(id);
}
Expand Down

0 comments on commit 59508f6

Please sign in to comment.