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
Added range property to nodes
Fixed whitespace not being created issue (solves #137 & #126)
Code Changes
Cleaned up parser code to make it understandable and slightly more efficient
Added comprehensive test for node ranges
Added basic whitespace parser test
Version
v4.1.0
Because a feature was added, I recommend bumping minor version.
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 aTextNode
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
range
property to nodesCode Changes
Version
v4.1.0
Because a feature was added, I recommend bumping minor version.
Related
126
137