utils/dom/createelement
@ckeditor/ckeditor5-utils/src/dom/createelement
Filtering
Functions
-
createElement( doc, name, attributes, [ children ] ) → SVGElementTagNameMap[ T ]
module:utils/dom/createelement~createElement:SVG_ELEMENT
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 ]
module:utils/dom/createelement~createElement:HTML_ELEMENT
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.
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.