Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2371382e387dabb8a8ac23c8bccb36b9fe175cc5
      
https://github.com/WebKit/WebKit/commit/2371382e387dabb8a8ac23c8bccb36b9fe175cc5
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-02 (Thu, 02 Apr 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-li-autoclosing-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-li-autoclosing.html
    M Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp

  Log Message:
  -----------
  HTMLFastPathParser fails to detect nested <li> elements when outer <li> is 
parsed via parseSpecificElements
https://bugs.webkit.org/show_bug.cgi?id=311342

Reviewed by Ryosuke Niwa.

The m_insideOfTagLi guard that prevents nested <li> (which requires
auto-closing per the HTML spec) was only set in parseElement(). When
<ul>/<ol> parse their children via parseSpecificElements<Li>(), the
outer <li> bypasses parseElement() entirely, so m_insideOfTagLi is
never set. A subsequent <li> inside that outer <li> is then incorrectly
accepted as a nested child instead of causing the fast parser to bail
out.

For example, "<ul><li><li></li></li></ul>" produced nested <li>
elements instead of the spec-required sibling <li> elements.

Fix by adding a parseChild override to the Li tag struct that sets
m_insideOfTagLi while parsing children, mirroring the existing pattern
used by the A tag struct for m_insideOfTagA. Uses save/restore (rather
than unconditional set/clear) because <li> can legitimately nest
through intervening <ul>/<ol>.

Test: imported/w3c/web-platform-tests/domparsing/innerhtml-li-autoclosing.html

* 
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-li-autoclosing-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-li-autoclosing.html:
 Added.
* Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp:
(WebCore::HTMLFastPathParser::TagInfo::Li::parseChild):

Canonical link: https://commits.webkit.org/310492@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to