Skip to content

Commit

Permalink
[parser] default options & cbs to empty objects
Browse files Browse the repository at this point in the history
fixes fb55#57
  • Loading branch information
fb55 committed Jun 23, 2013
1 parent 288bb93 commit b00177f
Showing 1 changed file with 24 additions and 30 deletions.
54 changes: 24 additions & 30 deletions lib/Parser.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
var Tokenizer = require("./Tokenizer.js");

var defaultOpts = {
xmlMode: false, //Special behavior for script/style tags by default
lowerCaseAttributeNames: false, //call .toLowerCase for each attribute name
lowerCaseTags: false //call .toLowerCase for each tag name
};

var defaultCbs = {
/*
This is just a plain object
so that the parser doesn't
throw if no arguments were
provided.
*/
/*
oncdataend,
oncdatastart,
onclosetag,
oncomment,
oncommentend,
onerror,
onopentag,
onprocessinginstruction,
onreset,
ontext
*/
};
/*
Options:
xmlMode: Special behavior for script/style tags (true by default)
lowerCaseAttributeNames: call .toLowerCase for each attribute name (true if xmlMode is `false`)
lowerCaseTags: call .toLowerCase for each tag name (true if xmlMode is `false`)
*/

/*
Callbacks:
oncdataend,
oncdatastart,
onclosetag,
oncomment,
oncommentend,
onerror,
onopentag,
onprocessinginstruction,
onreset,
ontext
*/

var formTags = {
input: true,
Expand Down Expand Up @@ -77,10 +73,8 @@ var voidElements = {
};

function Parser(cbs, options){
if(!options) options = defaultOpts;
if(!cbs) cbs = defaultCbs;
this._options = options;
this._cbs = cbs;
this._options = options || {};
this._cbs = cbs || {};

this._tagname = "";
this._attribname = "";
Expand Down

0 comments on commit b00177f

Please sign in to comment.