Skip to content

Commit

Permalink
sometimes the prevElement doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Swizec committed Oct 7, 2010
1 parent 1fe5e0f commit 9e74ff8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/node-htmlparser.js
Expand Up @@ -249,8 +249,11 @@ Parser.prototype.parseTags = function Parser$parseTags () {
prevElement.raw = prevElement.data = prevElement.raw + this._prevTagSep + element.raw;
element.raw = element.data = ""; //This causes the current element to not be added to the element list
}
else //Element is empty, so just append the last tag marker found
prevElement.raw = prevElement.data = prevElement.raw + this._prevTagSep;
else{ //Element is empty, so just append the last tag marker found
if (prevElement) {
prevElement.raw = prevElement.data = prevElement.raw + this._prevTagSep;
}
}
}
else //The previous element was not text
if (element.raw != "")
Expand Down

0 comments on commit 9e74ff8

Please sign in to comment.