Adds a eagerTextCapture option.#124
Adds a eagerTextCapture option.#124jails wants to merge 1 commit intofb55:masterfrom jails:eager-text-capture-option
Conversation
|
Wow, thanks a lot for your effort. This could (with some minor changes) definitely be merged, if the next step for this project wouldn't be a switch to In case you would be interested in porting this to
|
|
Thanks for the head up !
So I thought it would be interesting to let the function DomBuilder() {
this._parser = new Parser(this, {/* the required options for handlers */});
}
util.inherits(DomBuilder, Parser);
DomBuilder.prototype.ontext = function(text){ // handler logic };
DomBuilder.prototype.onxxx = function(){ // handler logic };
// etc.
var builder = new DomBuilder();
builder.parserComplete(/* some html */);So to keep the reasoning consistent, if Otherwise I will definilty have a look at high5, but I didn't understand what you mean by "IMHO there is no need for an additional option". By addionnal option you mean |
|
From a user perspective, having the handler modify options is opaque and unexpected. I'd like to avoid that. |
|
Agreed ! |
It's an alternative to #123.
Changes:
'ontext'will still the only event'eagerTextCapture'will control whether the'ontext'should be triggered as soon as some text is available or need to wait for the whole text sequence.'onparserinit'can return the options to be used for initializing the Tokenizer. this way it'll be possible to customize the options right from the handler.'onparserinit'call inside parser'sreset(). The handler has already been initialized with the parser, since the parser is the same after a reset the handler doesn't need to be initialized twice.'onreset'is enough for doing some cleanup imo.