Node: getRootNode() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

The getRootNode() method of the Node interface returns the context object's root, which optionally includes the shadow root if it is available.

Syntax

js
getRootNode()
getRootNode(options)

Parameters

options Optional

An object that sets options for getting the root node. The available options are:

  • composed: A boolean value that indicates whether the shadow root should be returned (false, the default), or a root node beyond shadow root (true).

Return value

An object inheriting from Node. This will differ in exact form depending on where you call getRootNode(); for example: