utils/dom/createelement
module
Type Definitions
module:utils/dom/createelement~ChildrenElementsmodule:utils/dom/createelement~HTMLElementAttributesmodule:utils/dom/createelement~SVGElementAttributes
Functions
createElement( doc, name, attributes, children? ) → SVGElementTagNameMap[ T ]module:utils/dom/createelement~createElement:SVG_ELEMENTCreates an SVG element with attributes and children elements.
Copy codecreateElement( 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: DocumentDocument used to create the element.
name: TName of the SVG element.
attributes: SVGElementAttributesObject where keys represent attribute keys and values represent attribute values.
children?: ChildrenElementsChild 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_ELEMENTCreates an HTML element with attributes and children elements.
Copy codecreateElement( 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: DocumentDocument used to create the element.
name: TName of the HTML element.
attributes?: HTMLElementAttributesObject where keys represent attribute keys and values represent attribute values.
children?: ChildrenElementsChild or any iterable of children. Strings will be automatically turned into Text nodes.
Returns
HTMLElementTagNameMap[ T ]HTML element.