-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback Support #907
base: gh-pages
Are you sure you want to change the base?
Callback Support #907
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use typeof minifyCSSResult !== 'undefined'
instead of overriding eslint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
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
,minifyCSS
andminifyJS
functions.Does not break any existing functionality.
Example Use:
Fixes #906