For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/engine/element-api/__ReplaceElement.md.
Lynx
  • English
  • __ReplaceElement

    Introduction

    Replaces an Element node with a specified node.

    Syntax

    __ReplaceElement(newChild: Element, oldChild: Element) : void;

    Parameters

    KeyDescription
    newChildThe new node that will replace the old node. If this node already exists in the Element tree, it will first be removed from its original position.
    oldChildThe original node that is 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);
    
    __ReplaceElement(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.