Skip to content

Citry UI: check for a shadow root before reading getRootNode().host #542

Open

Description

@JuroOravec

Problem

Several Citry UI browser scripts walk up through shadow roots like this:

for (let current = node; current; current = current.getRootNode().host ?? null) {
  if (ancestor.contains(current)) return true;
}

getRootNode() returns a ShadowRoot only when the node is inside a shadow tree. For a node in a detached subtree it returns the subtree's top element. If that element is an <a href> or an <area href>, .host is the link's URL host, a string such as "example.com". The loop then passes that string to contains() or calls getRootNode() on it, and the script throws a TypeError.

This has not been seen in practice. It needs a node that the component handles while it sits in a detached subtree under a link.

The scripts that TypeScript checks were fixed in #534. They now test instanceof ShadowRoot before reading .host, as _anchored_layer.py and _form_control_runtime.py do. The scripts below are not checked, because they are the sources of minified files.

Places to fix

  • ctour/runtime.source.js: composedContains (line 334) and the ancestor-root loop (line 355).
  • ccascader/runtime.source.js: composedContains (line 170) and the ancestor-root loop (line 193).
  • ccolor_picker/runtime.source.js: composedContains and listenForAncestorClose (lines 40 and 46).
  • cselect/runtime.source.js: the parent walk at line 121.
  • ccontext_menu/runtime.source.js: the parent walks at lines 536, 565 and 1453.

Fix

Activity

  1. added
    next-sprint
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions