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

domino

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domino

Server-side DOM implementation based on Mozilla's dom.js

  • 2.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
550K
decreased by-8.99%
Maintainers
2
Weekly downloads
 
Created

What is domino?

The 'domino' npm package is a server-side DOM implementation based on Mozilla's DOMParser. It allows you to create and manipulate DOM elements in a Node.js environment, similar to how you would in a browser. This is particularly useful for server-side rendering, web scraping, and testing.

What are domino's main functionalities?

Creating a DOM from HTML

This feature allows you to create a DOM structure from an HTML string. The code sample demonstrates creating a window and document object from an HTML string and then accessing an element by its ID.

const domino = require('domino');
const window = domino.createWindow('<div id="test">Hello World</div>');
const document = window.document;
console.log(document.getElementById('test').textContent); // Output: Hello World

Manipulating DOM elements

This feature allows you to manipulate DOM elements just like you would in a browser environment. The code sample shows how to change the text content of a DOM element.

const domino = require('domino');
const window = domino.createWindow('<div id="test">Hello World</div>');
const document = window.document;
const element = document.getElementById('test');
element.textContent = 'Hello Domino';
console.log(element.outerHTML); // Output: <div id="test">Hello Domino</div>

Parsing HTML

This feature allows you to parse an HTML string into a DOM document. The code sample demonstrates parsing an HTML string and querying an element using `querySelector`.

const domino = require('domino');
const document = domino.createDocument('<html><body><p>Hello World</p></body></html>');
console.log(document.querySelector('p').textContent); // Output: Hello World

Other packages similar to domino

FAQs

Package last updated on 16 Jul 2020

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