npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

minidom

v1.0.0

Published

Small DOM level 1 implementation

Downloads

524

Readme

minidom

A small JavaScript DOM. Implements DOM level 1, with textContent from level 3 and innerHTML and outerHTML getters. Only supports HTML documents.

Usage

var minidom = require("minidom");

var document = minidom('<!doctype><html><head><title>Hello</title><body><h1>Hi!</h1></body></html>');

expect(document.getElementsByTagName("h1")[0].textContent).toEqual("Hi!");

You can also access the DOM implementation used internally:

var dom = require("minidom/dom");

var document = minidom();
expect(document instanceof dom.Node).toBeTruthy();

Differences with JSDom

| | JSDom | minidom | | --- | --- | --- | | Runs Javascript in the page context | Yes | No | | CSSOM | Yes | No | | Loads remote resources | Yes | No | | HTML5 parsing algorithm | No | Yes* | | Runs in the browser | No | Yes** | | Awesome | Yes | Yes |

Basically minidom does a lot less, but often it's all you need.

* This means that the DOM representation is the same as you would get in the browser, but may not be suitable if you wish to preserve as much of the original formatting as possible. For example parsing <body>hi</body><head><title>hello</title> with minidom results in a document that looks like <html><head></head><body>hi<title>hello</title></body></html> , where as JSDom outputs <html><body>hi</body><head><title>hello</title></head></html>.

** This is probably very cool, although I have no idea why.

Supported API

Properties marked ⃠  are read-only

Node

  • ELEMENT_NODE
  • ATTRIBUTE_NODE
  • TEXT_NODE
  • CDATA_SECTION_NODE
  • ENTITY_REFERENCE_NODE
  • ENTITY_NODE
  • PROCESSING_INSTRUCTION_NODE
  • COMMENT_NODE
  • DOCUMENT_NODE
  • DOCUMENT_TYPE_NODE
  • DOCUMENT_FRAGMENT_NODE
  • NOTATION_NODE
  • children
  • nodeValue
  • parentNode
  • nodeName
  • attributes
  • firstChild
  • ownerDocument
  • readonly
  • lastChild
  • childNodes
  • nextSibling
  • previousSibling
  • insertBefore(/* Node */ newChild, /* Node*/ refChild)
  • replaceChild(/* Node */ newChild, /* Node */ oldChild)
  • removeChild(/* Node */ oldChild)
  • appendChild(/* Node */ newChild)
  • hasChildNodes()
  • cloneNode(/* bool */ deep, fn)
  • normalize()
  • toString()
  • raise(type, message, data)
  • textContent

Document (inherits from Node)

  • nodeType
  • contentType
  • doctype
  • documentElement
  • implementation
  • nodeName
  • tagName
  • nodeValue
  • attributes
  • ownerDocument
  • readonly
  • createElement(/* string */ tagName)
  • createDocumentFragment()
  • createTextNode(/* string */ data)
  • createComment(/* string */ data)
  • createCDATASection(/* string */ data)
  • createProcessingInstruction(/* string */ target, /* string */ data)
  • createAttribute(/* string */ name)
  • createEntityReference(/* string */ name)
  • createEntityNode(/* string */ name)
  • createNotationNode(/* string */ name, /* string */ publicId, /* string */ systemId)
  • appendChild(/* Node */ arg)
  • removeChild(/* Node */ arg)
  • getElementsByTagName(/* string */ name)
  • outerHTML

Element (inherits from Node)

  • nodeValue
  • tagName
  • nodeType
  • attributes
  • getAttribute(/* string */ name)
  • setAttribute(/* string */ name, /* string */ value)
  • removeAttribute(/* string */ name)
  • getAttributeNode(/* string */ name)
  • setAttributeNode(/* Attr */ newAttr)
  • removeAttributeNode(/* Attr */ oldAttr)
  • getElementsByTagName(/* string */ name)
  • outerHTML
  • innerHTML

Thanks

Made possible with large excerpts from JSDom, and the excellent parse5 implementation of the HTML5 parsing algorithm.

License

MIT license. See LICENSE.md for details.