Docs
Internals
stringToDOM()
⚠️

This function is part of the internal API. It is intended for developers creating their own frameworks. It is not recommended for general use.


stringToDOM()

Syntax: stringToDOM(content, svg)
Example: stringToDOM('<div>Hello World</div>')

The stringToDOM function takes a string of HTML or SVG and returns a DOM object. This is useful for creating DOM elements from strings.

import { stringToDOM } from 'million';
 
const dom = stringToDOM('<div>Hello World</div>');
 
dom.innerHTML; // 'Hello World'
dom.tagName; // 'DIV'
 
const svg = stringToDOM('<g><rect /></g>'); // creates SVG!