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

html-document

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-document

Partial implementation of document, HTMLElement for node

  • 0.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
187
increased by58.47%
Maintainers
1
Weekly downloads
 
Created
Source

html-document NPM version Build Status Code Climate Coverage

Partial implementation of the DOM, document for node.

Quick example

import Document from 'html-document'; // or var Document = require('html-document');
const document = new Document();

let textNode = document.createTextNode('Hello');
let h1 = document.createElement('h1');
h1.setAttribute('id', 'title');

h1.appendChild(textNode);
expect(h1.outerHTML, '<h1 id="title">Hello</h1>');

Purpose

The partial implementation allows you to build html like you would in the browser, with the DOM API.

This library will never implement all specifications of the W3C.

API

See the generated API here.

Examples

Inject window, document, Document, DocumentFragment, Node and Event in the global scope.

import 'html-document/lib/global'; // or var Document = require('html-document/lib/global');

let textNode = document.createTextNode('Hello');
expect(textNode.textContent, 'Hello');

Create an HTML layout

let document = new Document();
let fragment = document.createDocumentFragment();
fragment.appendChild(new Doctype());
let html = document.createElement('html');
fragment.appendChild(html);
let head = document.createElement('head');
html.appendChild(head);
let body = document.createElement('body');
html.appendChild(body);
expect(fragment.innerHTML, '<!DOCTYPE html><html><head></head><body></body></html>');

Keywords

FAQs

Package last updated on 14 Jul 2015

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