Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-lite

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-lite

A small DOM implementation for server-side

  • 23.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32
decreased by-48.39%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

Keywords

FAQs

Package last updated on 06 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc