Skip to content

Commit

Permalink
Use Node.prototype.getRootNode if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sepand Parhami committed Nov 8, 2016
1 parent 73f7b6c commit 2b67c5b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/dom_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ const getAncestry = function(node, root) {


/**
* @param {!Node} node
* @return {!Node} The root node of the DOM tree that contains node.
* @return {!Node} The root node of the DOM tree that contains this node.
* @this Node
*/
const getRoot = function(node) {
let cur = node;
const getRootNode = Node.prototype.getRootNode || function() {
let cur = this;
let prev = cur;

while (cur) {
Expand All @@ -68,7 +68,7 @@ const getRoot = function(node) {
* corresponding to node, if present.
*/
const getActiveElement = function(node) {
const root = getRoot(node);
const root = getRootNode.call(node);
return isDocumentRoot(root) ? root.activeElement : null;
};

Expand Down

0 comments on commit 2b67c5b

Please sign in to comment.