@todojs/

06.shadowRoot-parent

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>.host</title>
</head>
<body>
<div id="test"></div>
<script>
  const div        = document.querySelector ('#test');
  const shadowRoot = div.attachShadow ({mode : 'open'});
  console.assert (shadowRoot.parentElement === null);
  console.assert (shadowRoot.parentNode === null);
  shadowRoot.host.parentElement.style.backgroundColor = 'red';
</script>
</body>
</html>
result
console