taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

feat: Add range to nodes and fix whitespace issue (fixes #137) #138

Closed nonara closed 3 years ago

nonara commented 3 years ago

Abstract

It turns out that other AST parsers do create a TextNode for all whitespace (see https://astexplorer.net) The only which does not is the parser for angular templates, which it likely does because it's used in a very narrow context.

The issue ended up being that node-html-parser actually does create a TextNode for whitespace, but there were some cases in which that was failing to happen. This caused the behaviour to differ from other parsers and is the root of the issue laid out in #137.

Features / Fixes

Code Changes

Version

v4.1.0

Because a feature was added, I recommend bumping minor version.

Related

nonara commented 3 years ago

@taoqf Ready for review!

taoqf commented 3 years ago

Thank you.