Skip to content

Fix crash on template in svg or mathml namespace - #19

Open
SAY-5 wants to merge 1 commit into
syntax-tree:mainfrom
SAY-5:fix-svg-template-crash
Open

SAY-5 wants to merge 1 commit into
syntax-tree:mainfrom
SAY-5:fix-svg-template-crash

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 26, 2026 •

Copy link
Copy Markdown

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything or linked relevant results below
  • I made sure the docs are up to date
  • I included tests (or that’s not needed)

Description of changes

Closes #15.

parse5 only sets content on template nodes in the HTML namespace, so <svg><template> or <math><template> hits one(state, undefined) and throws. hastscript also unconditionally moves a template's children into .content regardless of namespace, so the fix has to put those children back on the element when there is no real parse5 content to use instead.

Added a test for both the svg and mathml case.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@github-actions github-actions Bot added the 👋 phase/new Post is being triaged automatically label Aug 26, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤞 phase/open Post is being triaged manually

Development

Successfully merging this pull request may close these issues.

TypeError on template in the SVG or MathML namespace

1 participant