Create benchmark - MeasureThat.net

x
1
11
<html><head>
1
<div>
2
  
3
</div><div><div>
4
  <div>
5
  <div>
6
  <div>
7
  <div>
8
  <div>
9
  
10
</div>
11
</div>
12
</div>
13
</div><div>
14
  
15
</div>
16
</div><div>
17
  
18
</div>
19
</div>
20
  
21
</div><div>
22
  
23
</div><div>
24
  
25
</div><div>
26
  
27
</div><div>
28
  
29
</div><div>
30
  
31
</div><div>
32
  
33
</div>
57
            </div>


x
9
1
1
// language=HTML
  • x
    13
    8
    13
    1
    const elements = [...(function *deepDescendents(root) {
    2
      for (const child of root.childNodes) {
    3
        if (child instanceof Element) {
    4
          yield child.shadowRoot ?? child;
    5
        }
    6
      }
    7
      for (const child of root.childNodes) {
    8
        if (child instanceof Element) {
    9
          deepDescendents(child.shadowRoot ?? child);
    10
        }
    11
      }
    12
    })(document)];
  • x
    19
     
    1
    const elements = [...(function* deepDescendents(root) {
    2
      const walkers = [document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT)];
    3
      for (const walker of walkers) {
    4
        let node: Element | null = null;
    5
        while ((node = walker.nextNode() as Element | null)) {
    6
          if (!node.shadowRoot) {
    7
            yield node;
    8
          } else {
    9
            yield node.shadowRoot;
    10
            walkers.push(
    11
              document.createTreeWalker(node.shadowRoot, NodeFilter.SHOW_ELEMENT)
    12
            );
    13
          }
    14
        }
    15
      }
    16
    })(document)];
    17
Validation log:
  • Checking necessary properties...
  • Loading iframe for testing...
  • Checking necessary properties...Done.
  • Taking care of HTML Preparation code...
  • Loading iframe for testing...Done.
  • Attempting to run benchmark...
  • Error when running benchmark: Unexpected token ':'
Validate benchmark  Cancel

© 2023 - MeasureThat.net (Version: 1.3.3.0)