Lightweight Node.js library implementing the DOM Living Standard.
The purpose of this library is to provide a basic implementation of the DOM. It excludes the HTML elements (e.g. body, audio) and several interfaces. Provides the minimum necessary for creating and handling nodes and elements.
Notable changes: (over v1.0.0-beta)
Provides missing Document
properties and DOMImplementation
interface
- Implement:
DOMImplementation
interface, entirely - Add:
document.URL
,document.documentURI
,document.origin
,document.compatMode
,document.characterSet
,document.charset
,document.inputEncoding
,document.contentType
properties - Add:
document.implementation
property - Add:
document.doctype
property - Add:
document.documentElement
property - Add:
document.createElementNS()
method
- Shadow DOM
- Events and Mutation Observers
- Custom Elements and custom element steps
- CSS and related methods/properties (e.g. the Element widths, positioning)
- Scripts
- Window (replaced by Context)
- querySelector() / querySelectorAll()
See here the full list of what is implemented and what is missing.
Install via npm:
npm install dom-slim
Usage example
const DOM = require('dom-slim');
// Create a Document
const document = DOM.createDocument();
// Create some Element nodes
const html = document.createElement('html');
const head = document.createElement('head');
html.appendChild(head);
const body = document.createElement('body');
html.appendChild(body);
/**
* Resulting DOM:
*
* html
* - head
* - body
*/