Registry / web-framework / domino

domino

JSON →
library0.1.5jsnpmunverified

Domino provides a lightweight, server-side implementation of the Document Object Model (DOM) for Node.js, currently at version 2.1.7. Its primary goal is to enable server-side rendering and manipulation of HTML structures without the overhead of a full browser engine. It prioritizes performance and simplicity over strict compliance with the latest DOM specifications or script execution. Domino adheres to DOM Level 4, meaning certain modern browser APIs and behaviors (like Attributes inheriting Node) are not present. It explicitly does not execute scripts or download external resources, making it unsuitable for scraping pages that rely heavily on client-side JavaScript. The library offers both a standard `createWindow` / `createDocument` API and an incremental HTML parser for streaming input. It differentiates itself from alternatives like `jsdom` by not aiming to run untrusted code, avoiding proxy facades and leading to a more performant internal structure, especially for tree modification if `Node#childNodes` is avoided.

npm install domino
INSTALL
IMPORT
SIG · DOMINO
D
domino
web-frameworkjavascriptv0.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

domino
import * as domino from 'domino';
const domino = require('domino');
While CommonJS `require` is shown in the README, modern TypeScript/ESM usage prefers named or wildcard imports. The library ships types.
createWindow
import { createWindow } from 'domino';
const window = domino.createWindow(...);
One of the primary entry points for creating a new DOM environment, allowing a base URL to be specified.
createDocument
import { createDocument } from 'domino';
const document = domino.createDocument(...);
An alternative, more direct way to create a Document object without an associated Window.
Element
import { impl } from 'domino'; const { Element } = impl;
import { Element } from 'domino';
Specific DOM interfaces like `Element` are exposed via the `impl` namespace within the main domino export, not as direct named exports from the root module.

Demonstrates creating a DOM window/document, querying elements, verifying element types, and basic DOM manipulation.

import { createWindow, impl } from 'domino'; const { Element } = impl; // Create a new window and document with initial HTML content const window = createWindow('<h1>Hello domino world</h1><p id="msg">This is a server-side DOM.</p>', 'http://example.com'); const document = window.document; // Query elements using standard DOM APIs const h1 = document.querySelector('h1'); const messageParagraph = document.getElementById('msg'); console.log(`H1 content: ${h1?.innerHTML}`); console.log(`Paragraph text: ${messageParagraph?.textContent}`); // Verify element instance if (h1 instanceof Element) { console.log('h1 is an instance of Element.'); } // Manipulate the DOM const newParagraph = document.createElement('p'); newParagraph.textContent = 'This paragraph was added dynamically.'; document.body.appendChild(newParagraph); console.log('\nDocument after modification:'); console.log(document.body.outerHTML);
Debug
Known issues
breakingThe `Element.attributes` property is not a true JavaScript array; it's an object with `length` and `item(n)` methods, and indexed access (`[i]`), but lacks full array prototype methods like `map` or `forEach`. Direct iteration might require conversion to an array.
fix
To use array methods, convert `element.attributes` to an array first: `Array.from(element.attributes).map(...)` or `[...element.attributes].forEach(...)`.
affects: >=1.0.0
gotchaDomino is designed for 'building' pages, not scraping. It does not execute scripts (e.g., `<script>` tags) and does not download external resources (e.g., images, stylesheets, external scripts).
fix
Do not rely on client-side script execution or external resource loading. For dynamic content, manipulate the DOM programmatically. For resource fetching, handle it externally before injecting content.
affects: >=1.0.0
gotchaDomino strictly adheres to DOM Level 4. This means certain modern HTML5 DOM features and behaviors, such as `Attribute` nodes inheriting from `Node`, or deprecated HTML5 properties, are not implemented.
fix
Consult MDN's DOM Level 4 documentation for API compatibility. If you require full HTML5 compliance or newer DOM APIs, consider libraries like `jsdom`.
affects: >=1.0.0
gotchaFor optimal performance during tree modification (inserting/removing children), it is recommended to traverse the DOM using `Node#firstChild`, `Node#nextSibling`, `Node#lastChild`, or `Node#previousSibling` rather than repeatedly accessing `Node#childNodes`.
fix
Refactor DOM modification logic to avoid repeated access to `Node#childNodes` if performance is critical for large trees or frequent changes.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: element.attributes.map is not a function
Attempting to use array prototype methods directly on `Element.attributes`, which is an array-like object but not a true JavaScript array.
fix
Convert `element.attributes` to an array before using array methods: `Array.from(element.attributes).map(...)` or `[...element.attributes].forEach(...)`.
ReferenceError: document is not defined
Attempting to access the global `document` object in a Node.js environment without creating a `domino` document first.
fix
Always create a `domino` `window` or `document` instance explicitly using `createWindow()` or `createDocument()`, then access the document via `window.document` or the returned `document` object.
Scripts embedded in HTML are not executing as expected.
Domino explicitly does not execute JavaScript code embedded in the parsed HTML content, as it prioritizes performance and server-side rendering without browser engine overhead.
fix
Client-side scripts are not supported. Any dynamic behavior must be implemented programmatically using Domino's DOM manipulation APIs in your Node.js code, or by pre-rendering the final HTML.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
domino — npm install domino · libregistry