Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 14x 714x 714x 495x 714x 14x 15x 15x 21x | import { each } from 'support/utils/array';
import { attr } from 'support/dom/attribute';
import { contents } from 'support/dom/traversal';
import { removeElements } from 'support/dom/manipulation';
/**
* Creates a div DOM node.
*/
export const createDiv = (classNames?: string): HTMLDivElement => {
const div = document.createElement('div');
if (classNames) {
attr(div, 'class', classNames);
}
return div;
};
/**
* Creates DOM nodes modeled after the passed html string and returns the root dom nodes as a array.
* @param html The html string after which the DOM nodes shall be created.
*/
export const createDOM = (html: string): ReadonlyArray<Node> => {
const createdDiv = createDiv();
createdDiv.innerHTML = html.trim();
return each(contents(createdDiv), (elm) => removeElements(elm));
};
|