gulp-tweakdom
Wraps up jsdom in a easy-to-use Gulp API that allows for DOM manipulation. Doesn't run code, load resources etc. Install via NPM or Yarn.
Usage-
const gulp = ;const tweakdom = ; gulp
If you return a node from the mutator function, its .innerHTML
will be used for output instead of the whole document.
This can be useful if you're manipulating a HTML partial, as jsdom will otherwise assume <head>
, <body>
etc.
For example, to modify this patial-
Test file
Use a mutator that returns document.body
, as jsdom parses the partial there-
{ documenttextContent = 'Hooray, partial'; return documentbody;}
TODO
- Don't use jsdom, it's an enormous dependency.