Skip to content

SynchronizedOverlay.ts TypeError: can't access property lastChild #1304

@MathieuB1

Description

@MathieuB1

Hi Team,

Can you please ensure that this function is robust by adding this change? Dont know what's the impact on existing test cases.

File: SynchronizedOverlay.ts

 * @param {Node} node The node to remove the children from.
 */
function removeChildren(node: Node) {
  while (node.lastChild) {
    node.removeChild(node.lastChild);
  }
}

Error:

removeChildren - SynchronizedOverlay.ts:22:9
TypeError: can't access property "lastChild", node is null

Fix Proposal:

function removeChildren(node: Node) {
  if (!node) {
    return;
  }
  while (node.lastChild) {
    node.removeChild(node.lastChild);
  }
}

Many thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions