← Back to DOM domain

DOM.getContainerForNode

Returns the query container of the given node based on container query conditions: containerName, physical and logical axes, and whether it queries scroll-state or anchored elements. If no axes are provided and queriesScrollState is false, the style container is returned, which is the direct parent or the closest element with a matching container-name.

Domain: DOM experimental

Parameters

NameTypeDescription
nodeIdNodeId
containerName (optional)string
physicalAxes (optional)PhysicalAxes
logicalAxes (optional)LogicalAxes
queriesScrollState (optional)boolean
queriesAnchored (optional)boolean

Returns

NameTypeDescription
nodeIdNodeIdThe container node for the given node, or null if not found.

Example Request

{
  "id": 1,
  "method": "DOM.getContainerForNode",
  "params": {
    "nodeId": 1
  }
}

Example Response

{
  "id": 1,
  "result": {
    "nodeId": 3
  }
}

Usage in Node.js

const result = await send('DOM.getContainerForNode', {"nodeId": 1});
console.log(result);
// {"nodeId": 3}