Skip to content

Correctly close HTML <div> in release.tx #3010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2024
Merged

Correctly close HTML <div> in release.tx #3010

merged 1 commit into from
Apr 25, 2024

Conversation

JRaspass
Copy link
Contributor

I actually noticed this while testing MetaCPAN with the Ladybird browser where is kindly spat out:

187047.691 WebContent(331600): Expected <li> current node, but had <div>

Which came from

    // -> An end tag whose tag name is "li"
    if (token.is_end_tag() && token.tag_name() == HTML::TagNames::li) {
        // If the stack of open elements does not have an li element in list item scope, then this is a parse error; ignore the token.
        if (!m_stack_of_open_elements.has_in_list_item_scope(HTML::TagNames::li)) {
            log_parse_error();
            return;
        }

        // Otherwise, run these steps:
        // 1. Generate implied end tags, except for li elements.
        generate_implied_end_tags(HTML::TagNames::li);

        // 2. If the current node is not an li element, then this is a parse error.
        if (current_node().local_name() != HTML::TagNames::li) {
            log_parse_error();
            dbgln("Expected <li> current node, but had <{}>", current_node().local_name());
        }

        // 3. Pop elements from the stack of open elements until an li element has been popped from the stack.
        m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::li);
        return;
    }

But you can also see the error when viewing the source of a MetaCPAN dist page in Firefox:
image

And this new markup matches what Firefox munges it into anyways:
image

@haarg haarg merged commit 93ae29c into metacpan:master Apr 25, 2024
@JRaspass JRaspass deleted the patch-1 branch April 25, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants