An ElementProxy instance pointing to the sandbox DOM container, serving as the default rendering target for ctx.render(). It is available in scenarios where a rendering container exists, such as JSBlock, JSField, JSItem, and JSColumn.
| Scenario | Description |
|---|---|
| JSBlock | The DOM container for the block, used to render custom block content. |
| JSField / JSItem / FormJSFieldItem | The rendering container for a field or form item (usually a <span>). |
| JSColumn | The DOM container for a table cell, used to render custom column content. |
Note:
ctx.elementis only available in RunJS contexts that have a rendering container. In contexts without a UI (such as pure backend logic), it may beundefined. It is recommended to perform a null check before use.
Recommended: All rendering should be performed via ctx.render(). Avoid using the DOM APIs of ctx.element directly (e.g., innerHTML, appendChild, querySelector, etc.).
| Advantage | Description |
|---|---|
| Security | Centralized security control to prevent XSS and improper DOM operations. |
| React Support | Full support for JSX, React components, and lifecycles. |
| Context Inheritance | Automatically inherits the application's ConfigProvider, themes, etc. |
| Conflict Handling | Automatically manages React root creation/unmounting to avoid multi-instance conflicts. |
ctx.element.innerHTMLis deprecated. Please usectx.render()instead.
When you need to open a Popover using the current element as an anchor, you can access ctx.element?.__el to get the raw DOM as the target:
Use
__elonly in scenarios like "using the current container as an anchor"; do not manipulate the DOM directly in other cases.
ctx.render(vnode) is called without a container argument, it renders into the ctx.element container by default.ctx.element is missing and no container is provided, an error will be thrown.ctx.render(vnode, customContainer).ctx.element is intended for internal use by ctx.render(). Directly accessing or modifying its properties/methods is not recommended.ctx.element will be undefined. Ensure the container is available or pass a container manually before calling ctx.render().innerHTML/outerHTML in ElementProxy are sanitized via DOMPurify, it is still recommended to use ctx.render() for unified rendering management.