Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including stringdom with all npm packages installed. Try it out:

var stringdom = require("stringdom")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

stringdom v0.2.0

A W3C DOM implementation powered by text

Stringdom Build Status

The W3C DOM powered by text. Built on top of htmlparser2 and CSSSelect.


This library is published on npm as "stringdom". Install it via:

$ npm install stringdom

It exports a single constructor function for Document objects. Documents can be initialized with a defaultView object (i.e. the global window reference) and the parsing options supported by htmlparser2.

var Document = require('stringdom');

var document = new Document();
var ul;

document.write('<h1>Soul Food Cafe</h1><ul></ul>');

ul = document.getElementsByTagName('ul')[0];

ul.innerHTML = '<li></li><li></li>';
document.querySelectorAll('li')[0].textContent = 'toasted white bread';
ul.lastChild.textContent = 'four fried chickens and Coke';

ul.setAttriubute('class', 'orders');

// '<h1>Soul Food Cafe</h1><ul class="orders"><li>toasted white bread</li><li>four fried chickens and a Coke</li></ul>';


  • Pseudoselectors The CSSSelect engine is extremely fast, but some of its optimizations preclude the use of certain pseudo selectors. This includes :first and :last.
  • Live NodeLists Unlike in true web browser contexts, all selections made with Stringdom are static--existing element collections will not be updated as their document is modified.


Copyright (c) 2014 Mike Pennisi
Licensed under the MIT Expat license.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free