Module

utils/dom/createelement

@ckeditor/ckeditor5-utils/src/dom/createelement

module

Filtering

Functions

  • createElement( doc, name, attributes, [ children ] ) → SVGElementTagNameMap[ T ]

    Creates an SVG element with attributes and children elements.

    createElement( document, 'mask', { xmlns: 'http://www.w3.org/2000/svg' } ); // <mask>
    createElement( document, 'mask', { xmlns: 'http://www.w3.org/2000/svg', id: 'foo' } ); // <mask id="foo">
    createElement( document, 'mask', { xmlns: 'http://www.w3.org/2000/svg' }, 'foo' ); // <mask>foo</mask>
    createElement( document, 'mask', { xmlns: 'http://www.w3.org/2000/svg' }, [ createElement(...) ] ); // <mask><...></mask>
    

    Type parameters

    T : extends keyof SVGElementTagNameMap

    Parameters

    doc : Document

    Document used to create the element.

    name : T

    Name of the SVG element.

    attributes : SVGElementAttributes

    Object where keys represent attribute keys and values represent attribute values.

    [ children ] : ChildrenElements

    Child or any iterable of children. Strings will be automatically turned into Text nodes.

    Returns

    SVGElementTagNameMap[ T ]

    SVG element.

  • createElement( doc, name, [ attributes ], [ children ] ) → HTMLElementTagNameMap[ T ]

    Creates an HTML element with attributes and children elements.

    createElement( document, 'p' ); // <p>
    createElement( document, 'p', { class: 'foo' } ); // <p class="foo">
    createElement( document, 'p', null, 'foo' ); // <p>foo</p>
    createElement( document, 'p', null, [ createElement(...) ] ); // <p><...></p>
    

    Type parameters

    T : extends keyof HTMLElementTagNameMap

    Parameters

    doc : Document

    Document used to create the element.

    name : T

    Name of the HTML element.

    [ attributes ] : HTMLElementAttributes

    Object where keys represent attribute keys and values represent attribute values.

    [ children ] : ChildrenElements

    Child or any iterable of children. Strings will be automatically turned into Text nodes.

    Returns

    HTMLElementTagNameMap[ T ]

    HTML element.