diff --git a/README.md b/README.md index f6bb644..1ec1182 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,6 @@ templaters should be parsed and minified.** - build on the foundations of [htmlparser2][fb55] - pluggable interface that allows to hook into each element -## Upcoming in release 2.0 - -- minification of inline javascript with uglify or similar - ## Usage To get the minified content make sure to provide a callback. Optional an options @@ -64,9 +60,12 @@ be useful if the HTML contains SVG or if you need to specific options to the par ```javascript var Minimize = require('minimize') , html = require('htmlparser2') - , minimize = new Minimize(new html.Parser( - new html.FeedHandler((this.emits('read')) - ), { /* options */ }); + , minimize = new Minimize( + new html.Parser( + new html.FeedHandler(minimize.emits('read')), + { /* options */ } + ) + ); minimize.parse(content, function (error, data) { console.log(data); diff --git a/lib/minimize.js b/lib/minimize.js index a563983..d6b6426 100644 --- a/lib/minimize.js +++ b/lib/minimize.js @@ -35,7 +35,8 @@ function Minimize(parser, options) { // Prepare the parser. // this.htmlparser = parser || new html.Parser( - new html.DomHandler(this.emits('read')), options.dom + new html.DomHandler(this.emits('read')), + options.dom ); // diff --git a/test/minimize-test.js b/test/minimize-test.js index 91fd07c..71ecfd5 100644 --- a/test/minimize-test.js +++ b/test/minimize-test.js @@ -62,6 +62,8 @@ describe('Minimize', function () { expect(minimize.htmlparser).to.have.property('custom', 'instance'); }); + it('can emit the parsed content to `minimize.read`'); + it('should start traversing the DOM as soon as HTML parser is ready', function (done) { var emit = sinon.spy(minimize, 'emit');