__ReplaceElements

Introduction

Replaces a list of Element nodes with a specified list of nodes.

Syntax

__ReplaceElements(parent: Element, newChildren: Array<Element>, oldChildren: Array<Element>) : void;

Parameters

KeyDescription
parentThe parent node whose child nodes will be batch-replaced.
newChildrenThe list of new nodes that will replace the old nodes.
oldChildrenThe list of original nodes that are being replaced.

Return Value

No return value.

Example

The frontend framework can perform the replacement operation as follows.

// main-thread.js
let newChild = __CreateElement('view', 0, {});

let oldChild = __CreateElement('view', 0, {});

let parent = __CreateElement('view', 0, {});

__AppendElement(parent, oldChild);

__ReplaceElements(parent, [newChild], [oldChild]);
Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.