Permalink
Browse files

Fixed 'prevElement' error pointed out by Swizec

  • Loading branch information...
1 parent 00fbea9 commit 83722ba414eb33984f623e604b296c7a0ab9b197 @tautologistics committed Nov 10, 2010
Showing with 10 additions and 9 deletions.
  1. +8 −7 lib/node-htmlparser.js
  2. +2 −2 lib/node-htmlparser.min.js
View
@@ -18,7 +18,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
***********************************************/
-/* v1.6.3 */
+/* v1.6.4 */
(function () {
@@ -244,17 +244,18 @@ function Parser (handler) {
element.type = ElementType.Text;
//If the previous element is text, append the current text to it
if (this._elements.length && this._elements[this._elements.length - 1].type == ElementType.Text) {
+ var prevElement = this._elements[this._elements.length - 1];
if (element.raw != "") {
- var prevElement = this._elements[this._elements.length - 1];
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
+ } else { //Element is empty, so just append the last tag marker found
prevElement.raw = prevElement.data = prevElement.raw + this._prevTagSep;
- }
- else //The previous element was not text
- if (element.raw != "")
+ }
+ } else { //The previous element was not text
+ if (element.raw != "") {
element.raw = element.data = element.raw;
+ }
+ }
}
}
}
Oops, something went wrong.

0 comments on commit 83722ba

Please sign in to comment.