Skip to content

Commit

Permalink
fixed whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Jun 21, 2012
1 parent 7750ec1 commit 04476a0
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ Parser.prototype._parseTags = function(force){
if(this._contentFlags & TagValues[elementData]){
//remove the flag
this._contentFlags ^= TagValues[elementData];
}
else {
} else {
this._writeSpecial(rawData, lastTagSep);
continue;
}
Expand All @@ -186,7 +185,7 @@ Parser.prototype._parseTags = function(force){
//TODO: This isn't a processing instruction, needs a new name
else if(this._cbs.onprocessinginstruction){
this._cbs.onprocessinginstruction(
"!" + this._parseTagName(elementData.substr(1)),
"!" + this._parseTagName(elementData.substr(1)),
elementData
);
}
Expand All @@ -195,7 +194,7 @@ Parser.prototype._parseTags = function(force){
else if(elementData.charAt(0) === "?"){
if(this._cbs.onprocessinginstruction){
this._cbs.onprocessinginstruction(
"?" + this._parseTagName(elementData.substr(1)),
"?" + this._parseTagName(elementData.substr(1)),
elementData
);
}
Expand All @@ -219,11 +218,11 @@ Parser.prototype._parseTags = function(force){
Parser.prototype._writeCDATA = function(data){
if(this._tagSep === ">" && data.substr(-2) === "]]"){
// CDATA ends
if(data.length !== 2 && this._cbs.ontext){
this._cbs.ontext(data.slice(0,-2));
}
this._contentFlags ^= SpecialTags[ElementType.CDATA];
if(this._cbs.oncdataend) this._cbs.oncdataend();
if(data.length !== 2 && this._cbs.ontext){
this._cbs.ontext(data.slice(0,-2));
}
this._contentFlags ^= SpecialTags[ElementType.CDATA];
if(this._cbs.oncdataend) this._cbs.oncdataend();
}
else if(this._cbs.ontext) this._cbs.ontext(data + this._tagSep);
};
Expand All @@ -242,11 +241,11 @@ Parser.prototype._writeComment = function(rawData){
Parser.prototype._writeSpecial = function(rawData, lastTagSep){
//if the previous element is text, append the last tag sep to element
if(this._wroteSpecial){
if(this._cbs.ontext) this._cbs.ontext(lastTagSep + rawData);
if(this._cbs.ontext) this._cbs.ontext(lastTagSep + rawData);
}
else{ //The previous element was not text
this._wroteSpecial = true;
if(rawData !== "" && this._cbs.ontext) this._cbs.ontext(rawData);
this._wroteSpecial = true;
if(rawData !== "" && this._cbs.ontext) this._cbs.ontext(rawData);
}
};

Expand Down Expand Up @@ -317,7 +316,7 @@ Parser.prototype._processOpenTag = function(data){
} else {
if(type !== ElementType.Tag){
this._contentFlags |= SpecialTags[type];
this._wroteSpecial = false;
this._wroteSpecial = false;
}
this._stack.push(name);
}
Expand Down

0 comments on commit 04476a0

Please sign in to comment.