DOM lite –

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
Current Tags
-
23.2.1
...
latest
(4 years ago)
45 Versions
-
23.2.1
[deprecated]
...
4 years ago
-
23.2.0
[deprecated]
...
4 years ago
-
23.1.0
[deprecated]
...
4 years ago
-
22.10.0
[deprecated]
...
4 years ago
-
22.9.0
[deprecated]
...
4 years ago
-
20.2.0
[deprecated]
...
7 years ago
-
0.5.1
[deprecated]
...
10 years ago
-
0.5.0
[deprecated]
...
11 years ago
-
0.4.0
[deprecated]
...
12 years ago
-
0.3.12
[deprecated]
...
12 years ago
-
0.3.11
[deprecated]
...
12 years ago
-
0.3.10
[deprecated]
...
12 years ago
-
0.3.9
[deprecated]
...
12 years ago
-
0.3.8
[deprecated]
...
12 years ago
-
0.3.7
[deprecated]
...
12 years ago
-
0.3.6
[deprecated]
...
12 years ago
-
0.3.5
[deprecated]
...
12 years ago
-
0.3.4
[deprecated]
...
12 years ago
-
0.3.3
[deprecated]
...
12 years ago
-
0.3.2
[deprecated]
...
12 years ago
-
0.3.1
[deprecated]
...
12 years ago
-
0.3.0
[deprecated]
...
12 years ago
-
0.2.1
[deprecated]
...
12 years ago
-
0.2.0
[deprecated]
...
12 years ago
-
0.1.7
[deprecated]
...
12 years ago
-
0.1.6
[deprecated]
...
12 years ago
-
0.1.5
[deprecated]
...
12 years ago
-
0.1.4
[deprecated]
...
12 years ago
-
0.1.3
[deprecated]
...
12 years ago
-
0.1.2
[deprecated]
...
12 years ago
-
0.1.1
[deprecated]
...
13 years ago
-
0.1.0
[deprecated]
...
13 years ago
-
0.0.16
[deprecated]
...
13 years ago
-
0.0.15
[deprecated]
...
13 years ago
-
0.0.14
[deprecated]
...
13 years ago
-
0.0.13
[deprecated]
...
13 years ago
-
0.0.12
[deprecated]
...
13 years ago
-
0.0.11
[deprecated]
...
13 years ago
-
0.0.8
[deprecated]
...
13 years ago
-
0.0.7
[deprecated]
...
13 years ago
-
0.0.6
[deprecated]
...
13 years ago
-
0.0.5
[deprecated]
...
13 years ago
-
0.0.4
[deprecated]
...
13 years ago
-
0.0.3
[deprecated]
...
13 years ago
-
0.0.1
[deprecated]
...
13 years ago