Stringdom
The W3C DOM powered by text. Built on top of htmlparser2 and CSSSelect.
Usage
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 = ; var document = ;var ul; document; ul = document0; ulinnerHTML = '<li></li><li></li>';document0textContent = 'toasted white bread';ullastChildtextContent = 'four fried chickens and Coke'; ul; console;// '<h1>Soul Food Cafe</h1><ul class="orders"><li>toasted white bread</li><li>four fried chickens and a Coke</li></ul>';
Limitations
- 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
NodeList
s 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.
License
Copyright (c) 2014 Mike Pennisi
Licensed under the MIT Expat license.