Callback Support#907
Callback Support#907RebeccaStevens wants to merge 16 commits intokangax:gh-pagesfrom RebeccaStevens:callback-support
Conversation
…t when a callback is given, if it finished synchronously.
… has finished parsing the code before continuing.
…completes. minifyJS and minifyCSS function are now passed a callback function.
…inue the parse loop once called.
|
I plan on adding documentation updates soon. |
|
As stated in #906 (comment), you need to preserve the signature of Any changes to that interface would be a breaking change and cannot be accepted. |
|
The signature of |
|
I see. Before I can perform a code review, please exclude any auto-generated files from the changeset, i.e. |
|
Changes to dist files have now been undone. |
|
Just did a rebase. |
|
Thanks - looking at the changes, one question jumps out - is Apologies for not mentioning this earlier - there are users would rely on that to perform pre/post-processing, outside the scope of minification. One way I can think of is similar to |
src/htmlminifier.js
Outdated
|
|
||
| // If the result is defined then minifyCSS completed synchronously. | ||
| // eslint-disable-next-line no-undefined | ||
| if (minifyCSSResult !== undefined) { |
There was a problem hiding this comment.
Please use typeof minifyCSSResult !== 'undefined' instead of overriding eslint
|
Does |
I seem to have trouble validating that - the following test file is used: // test.js
var HTMLParser = require('./src/htmlparser').HTMLParser;
var input = require('fs').readFileSync('./index.html', 'utf8');
function log(prefix) {
return function() {
var args = [].slice.call(arguments);
args.unshift(prefix);
console.log.apply(console, args);
};
}
new HTMLParser(input, {
start: log('start'),
end: log('end'),
chars: log('chars'),
comment: log('comment')
});On current HEAD of ... whereas with this PR: |
|
I'll look into that tomorrow and make the necessary change to get it working. |
Adds callback support to
minify,minifyCSSandminifyJSfunctions.Does not break any existing functionality.
Example Use:
Fixes #906