Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Aug 6, 2020
1 parent a9f15c4 commit 039402e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lighthouse-core/lib/page-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ function ultradumbBenchmark() {
*/
/* istanbul ignore next */
function getNodePath(node) {
// For our purposes, there's no worthwhile difference between shadow root and document fragment
// We can consider them entirely synonymous.
const isShadowRoot = node => node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
const getNodeParent = node => isShadowRoot(node) ? node.host : node.parentNode;

/** @param {Node} node */
function getNodeIndex(node) {
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
if (isShadowRoot(node)) {
// User-agent shadow roots get 'u'. Non-UA shadow roots get 'a'.
return 'a';
}
Expand All @@ -188,10 +193,6 @@ function getNodePath(node) {
return index;
}

function getNodeParent(node) {
return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.host : node.parentNode
}

const path = [];
while (node && !!getNodeParent(node)) {
const index = getNodeIndex(node);
Expand Down

0 comments on commit 039402e

Please sign in to comment.