Skip to content
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

Problem with template inside button #2271

Closed
felixscheinost opened this issue Feb 20, 2025 · 1 comment
Closed

Problem with template inside button #2271

felixscheinost opened this issue Feb 20, 2025 · 1 comment
Labels
fixed An {bug|improvement} that has been {fixed|implemented}
Milestone

Comments

@felixscheinost
Copy link

Probably related to #2258.

Parsing the following HTML even with master (checked out 5d31cac at the moment), doesn't work:

<button>
  <template>
    <button></button>
  </template>
</button>

I think that HTML should be valid according to spec. MDN says that template is allowed inside every element that accepts phrasing content and buttons accept phrasing content.

I also put that snippet through https://validator.w3.org which passed:

Image

Still it doesn't get parsed correctly. I added a test to HtmlParserTest. The test currently passes that way, which is incorrect:

    @Test void templateInButton() {
        String html = "<button> <template><button></button></template> </button>";
        Document doc = Jsoup.parse(html);
        assertEquals("<button><template></template></button><button></button>",
                TextUtil.stripNewlines(doc.body().html()));
    }

We can see that the inner button ends up being interpreted as a sibling of the outer button.

@jhy jhy closed this as completed in b875b92 Feb 24, 2025
@jhy jhy added the fixed An {bug|improvement} that has been {fixed|implemented} label Feb 24, 2025
@jhy jhy added this to the 1.19.1 milestone Feb 24, 2025
@jhy
Copy link
Owner

jhy commented Feb 24, 2025

Thanks, fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed An {bug|improvement} that has been {fixed|implemented}
Projects
None yet
Development

No branches or pull requests

2 participants