yarn htmlparser2 12.0.0

5 hours ago

What's Changed

This release aligns HTML parsing with the WHATWG spec Almost all changes are to HTML mode only — XML mode is unaffected unless noted.

Raw-text & RCDATA tags

  • <iframe>, <noembed>, <noframes>, and <plaintext> are now raw-text tags, their content is no longer parsed as HTML
  • <textarea> now decodes entities like <title> already did
  • Self-closing <script/>, <style/>, etc. now enter their raw-text state (the / is ignored per spec) unless recognizeSelfClosing is enabled

SVG & MathML

  • Tag names inside <svg> are case-adjusted per spec (foreignObject, clipPath, etc.)
  • CDATA sections inside foreign content are treated as text
  • Special-tag detection is disabled inside foreign content
  • Stray </svg> / </math> no longer corrupt the parser's context tracking

Comments & declarations

  • <!-->, <!--->, <!->, <!> now parse as valid comments per spec
  • <?…> and non-DOCTYPE <!…> in HTML mode emit bogus comments instead of being silently dropped
  • <!DOCTYPEhtml> (no space) is recognized as a DOCTYPE
  • Unclosed comments, <!DOCTYPE, <?…, <![CDATA[… at EOF emit the correct token type

Implicit open/close

  • <h1><h6> implicitly close other headings
  • <a> closes a previous <a>
  • Nested <form> is ignored when one is already open
  • <image> is rewritten to <img> outside foreign content
  • </> is silently ignored instead of emitted as text

Other fixes

  • Fixed reset() not clearing attribute state, which could leak data across parseComplete() calls

#2387

Full Changelog: v11.0.0...v12.0.0

Don't miss a new htmlparser2 release

NewReleases is sending notifications on new releases.