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/__CreateElement.md.
Lynx
  • English
  • __CreateElement

    Introduction

    Creates an Element object.

    Syntax

    __CreateElement(tagName: string, parentComponentUniqueID: number, info?: object) : Element;

    Parameters

    KeyDescription
    tagNameA string that specifies the type of Element to create, which corresponds to the LynxUI tagName, such as input. Built-in Elements like view, image, etc. cannot use this interface and must use their respective Create APIs.
    parentComponentUniqueIDThe Unique Component ID of the ComponentElement that creates this Element, which is a number.
    infoAdditional information required when creating the Element; this parameter can be omitted.

    Return Value

    The return value is currently a Value_RefCounted type of lepus::Value, which is implemented as base::scoped_refptr<Element>.

    Note

    base::scoped_refptr<Element> manages the lifecycle of the Element based on reference counting. Therefore, the frontend framework can hold this return value to manage the Element's lifecycle. The Element will only be destroyed when the frontend framework no longer holds it and the Element is removed from the tree.

    Example

    The frontend framework can process the corresponding frontend tags into render directives as follows.

    <input />
    // main-thread.js
    let element = __CreateElement('input', 0, {});
    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.