Skip to main content

Class: ElementDOMSlot

lexical.ElementDOMSlot

A utility class for managing the DOM children of an ElementNode

Constructors

constructor

new ElementDOMSlot(element, before?, after?): ElementDOMSlot

Parameters

NameTypeDescription
elementHTMLElementThe element returned by createDOM
before?null | NodeAll managed children will be inserted before this node, if defined
after?null | NodeAll managed children will be inserted after this node, if defined

Returns

ElementDOMSlot

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:80

Properties

after

after: null | Node

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:79


before

before: null | Node

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:78


element

element: HTMLElement

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:77

Methods

getFirstChild

getFirstChild(): null | ChildNode

Returns the first managed child of this node, which will either be this.after.nextSibling or this.element.firstChild, and will never be this.before if it is defined.

Returns

null | ChildNode

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:153


insertChild

insertChild(dom): this

Insert the given child before this.before and any reconciler managed line break node, or append it if this.before is not defined

Parameters

NameType
domNode

Returns

this

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:114


removeChild

removeChild(dom): this

Remove the managed child from this container, will throw if it was not already there

Parameters

NameType
domNode

Returns

this

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:126


replaceChild

replaceChild(dom, prevDom): this

Replace managed child prevDom with dom. Will throw if prevDom is not a child

Parameters

NameTypeDescription
domNodeThe new node to replace prevDom
prevDomNodethe node that will be replaced

Returns

this

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:140


withAfter

withAfter(after): ElementDOMSlot

Return a new ElementDOMSlot where all managed children will be inserted after this node

Parameters

NameType
afterundefined | null | Node

Returns

ElementDOMSlot

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:101


withBefore

withBefore(before): ElementDOMSlot

Return a new ElementDOMSlot where all managed children will be inserted before this node

Parameters

NameType
beforeundefined | null | Node

Returns

ElementDOMSlot

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:95


withElement

withElement(element): ElementDOMSlot

Return a new ElementDOMSlot with an updated root element

Parameters

NameType
elementHTMLElement

Returns

ElementDOMSlot

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:107