unstale

npm / htmlparser2

htmlparser2

What changed in htmlparser2 10 to 12, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-28.

17 breaking1 new APIs and options8 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli 0.2.9 on npm

htmlparser2 1217 changes

Breaking changes 11

  • In HTML mode, processing instructions and non-DOCTYPE declarations emit bogus comments instead of being silently dropped.

    12.0.0release notes

  • CDATA sections inside foreign content are treated as text.

    12.0.0release notes

  • An empty end tag is silently ignored rather than emitted as text.

    12.0.0release notes

  • An h1–h6 element implicitly closes other headings.

    12.0.0release notes

  • image is rewritten to img outside foreign content.

    12.0.0release notes

  • A nested form is ignored when another form is already open.

    12.0.0release notes

  • iframe, noembed, noframes, and plaintext content is no longer parsed as HTML.

    12.0.0release notes

  • Self-closing script and style tags enter raw-text state when recognizeSelfClosing is not enabled; the slash is ignored per spec.

    12.0.0release notes

  • Special-tag detection is disabled inside foreign content.

    12.0.0release notes

  • Tag names inside svg are adjusted per spec, including foreignObject and clipPath.

    12.0.0release notes

  • textarea now decodes entities, matching title behavior.

    12.0.0release notes

Fixes and other changes 6

  • An a element closes a previously open a element.

    12.0.0release notes

  • DOCTYPE declarations without a space after DOCTYPE are recognized.

    12.0.0release notes

  • Unclosed comments, DOCTYPEs, processing instructions, and CDATA sections emit the correct token type at EOF.

    12.0.0release notes

  • Stray svg and math end tags no longer corrupt parser context tracking.

    12.0.0release notes

  • Several comment forms that were previously invalid are now parsed as valid comments per spec.

    12.0.0release notes

  • reset() now clears attribute state, preventing data from leaking across parseComplete() calls.

    12.0.0release notes

htmlparser2 118 changes

Breaking changes 5

  • The module is ESM only; CommonJS require() is no longer supported in legacy environments, so use import instead.

    11.0.0release notes

  • The minimum supported Node.js version is now 20.19.0.

    11.0.0release notes

  • The deprecated parseDOM function was removed.

    11.0.0release notes

  • In xmlMode, <!--> is no longer treated as a complete comment.

    11.0.0release notes

  • XML processing instructions now require the full ?> closing sequence instead of just >.

    11.0.0release notes

New APIs and options 1

  • Added WebWritableStream for the Web Streams API, enabling direct piping from fetch() response bodies into the parser.

    11.0.0release notes

Fixes and other changes 2

  • In HTML mode, comments accept --!> as a closing sequence, and <!--> is recognized as an empty comment.

    11.0.0release notes

  • reset() now clears isSpecial and sequenceIndex state, preventing incorrect parsing after reuse.

    11.0.0release notes

htmlparser2 101 changes

Breaking changes 1

  • Test files are no longer included in the published module, changing the files available to consumers of the package.

    10.1.0release notes