Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

ShadowDOM Support #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = function(eruda) {
if (!node) {
children = [document.documentElement]
} else {
children = toArr(node.childNodes)
children = (node.shadowRoot) ? toArr(node.shadowRoot.childNodes) : toArr(node.childNodes)
}

const container = $container.get(0)
Expand All @@ -112,14 +112,13 @@ module.exports = function(eruda) {

$tag.addClass('eruda-tree-item')
if (child.nodeType === child.ELEMENT_NODE) {
const childCount = child.childNodes.length
const expandable = childCount > 0
const childCount = (child.shadowRoot) ? child.shadowRoot.childNodes.length : child.childNodes.length;
const expandable = childCount > 0;
const data = {
...getHtmlTagData(child),
hasTail: expandable
}
const hasOneTextNode =
childCount === 1 && child.childNodes[0].nodeType === child.TEXT_NODE
const hasOneTextNode = childCount === 1 && ((child.shadowRoot) ? child.shadowRoot.childNodes[0].nodeType : child.childNodes[0].nodeType) === child.TEXT_NODE;
if (hasOneTextNode) {
data.text = child.childNodes[0].nodeValue
}
Expand Down