UNPKG

@test-runner/web

Version:
54 lines (36 loc) 1.55 kB
[![view on npm](https://img.shields.io/npm/v/dommo.svg)](https://www.npmjs.org/package/dommo) [![npm module downloads](https://img.shields.io/npm/dt/dommo.svg)](https://www.npmjs.org/package/dommo) [![Build Status](https://travis-ci.org/75lb/dommo.svg?branch=master)](https://travis-ci.org/75lb/dommo) [![Dependency Status](https://badgen.net/david/dep/75lb/dommo)](https://david-dm.org/75lb/dommo) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard) ## dommo An isomorphic, load-anywhere function to convert an HTML string to a DOM tree. ```js import dommo from './node_modules/dommo/index.mjs' /* passing in HTML with a single root returns an element */ const el = dommo('<some-element>something</some-element>') document.body.appendChild(el) /* passing in HTML with multiple root elements returns a DocumentFragment */ const frag = dommo('<some-element>something</some-element><some-element>something</some-element>') document.body.appendChild(frag) ``` ### Load anywhere This library can be loaded anywhere, natively without transpilation. Node.js: ```js const dommo = require('dommo') ``` Within Node.js with ECMAScript Module support enabled: ```js import dommo from 'dommo' ``` Within a modern browser ECMAScript Module: ```js import dommo from './node_modules/dommo/index.mjs' ``` Old browser (adds `window.dommo`): ```html <script nomodule src="./node_modules/dommo/dist/index.js"></script> ``` * * * &copy; 2018-19 Lloyd Brookes \<75pound@gmail.com\>.