23.2.1 • Published 1 year ago

dom-lite v23.2.1

Weekly downloads
89
License
MIT
Repository
github
Last release
1 year ago

DOM lite Coverage Size Buy Me A Tea

A small DOM implementation for testing, server-side rendering and working with html files.

Examples

const { document, DOMParser, XMLSerializer } = require("dom-lite");
const { XMLHttpRequest } = require("dom-lite/xmlhttprequest");

// Use XMLHttpRequest in server side
var xhr = new XMLHttpRequest()
xhr.open("GET", "https://litejs.com")
xhr.responseType = "document"
xhr.onload = function() {
	var doc = xhr.responseXML
	// Work with DOM in familiar way
	console.log(doc.querySelector("title").textContent)
}
xhr.send()

// Build DOM manually
const el = document.createElement("h1");
el.id = 123;
el.className = "large";

const fragment = document.createDocumentFragment();
const text1 = document.createTextNode("hello");
const text2 = document.createTextNode(" world");

fragment.appendChild(text1);
fragment.appendChild(text2);
el.appendChild(fragment);

el.innerHTML;
// hello world
el.innerHTML = "<b>hello world</b>";
el.toString();
// <h1 id="123" class="large"><b>hello world</b></h1>

// minify output
el.toString(true);
// <h1 id=123 class=large><b>hello world</b></h1>

el.querySelectorAll("b");
// [ "<b>hello world</b>" ]

Contributing

Follow Coding Style Guide

Run tests

npm install
npm test

External links

GitHub repo | npm package | DOM spec | Selectors Level 3 | Coveralls coverage
Buy Me A Tea

Licence

Copyright (c) 2014-2023 Lauri Rooden <lauri@rooden.ee>
The MIT License

23.2.1

1 year ago

23.2.0

1 year ago

23.1.0

1 year ago

22.10.0

2 years ago

22.9.0

2 years ago

20.2.0

4 years ago

0.5.1

8 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.12

9 years ago

0.3.11

9 years ago

0.3.10

9 years ago

0.3.9

9 years ago

0.3.8

9 years ago

0.3.7

9 years ago

0.3.6

9 years ago

0.3.5

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.7

9 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.1

10 years ago