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

Cannot compile unknown node login #44

Closed
4 tasks done
albinekb opened this issue Nov 18, 2024 · 4 comments
Closed
4 tasks done

Cannot compile unknown node login #44

albinekb opened this issue Nov 18, 2024 · 4 comments
Labels
🤞 phase/open Post is being triaged manually

Comments

@albinekb
Copy link

albinekb commented Nov 18, 2024

Initial checklist

Affected packages and versions

hast-util-to-html@9.0.3

Link to runnable example

No response

Steps to reproduce

const processor = unified()
    .use(rehypeParse, { fragment: true, emitParseErrors: true })
    .use(rehypeFormat, { blanks: [], indent: 0 })
    .use(rehypeStringify, { allowParseErrors: true})
    
const vfile = await processor.process('<button type="login">Click me</button>')

const text = vfile.toString()
Cannot compile unknown node `login`
    at unknown (node_modules/.pnpm/hast-util-to-html@9.0.3/node_modules/hast-util-to-html/lib/handle/index.js:46:9)
    at one (node_modules/.pnpm/zwitch@2.0.4/node_modules/zwitch/index.js:108:17)
    at Object.one (node_modules/.pnpm/hast-util-to-html@9.0.3/node_modules/hast-util-to-html/lib/index.js:234:10)
    at Object.all (node_modules/.pnpm/hast-util-to-html@9.0.3/node_modules/hast-util-to-html/lib/index.js:253:27)
    at element (node_modules/.pnpm/hast-util-to-html@9.0.3/node_modules/hast-util-to-html/lib/handle/element.js:78:25)
    at one (node_modules/.pnpm/zwitch@2.0.4/node_modules/zwitch/index.js:108:17)
    at Object.one (node_modules/.pnpm/hast-util-to-html@9.0.3/node_modules/hast-util-to-html/lib/index.js:234:10)
    at Object.all (node_modules/.pnpm/hast-util-to-html@9.0.3/node_modules/hast-util-to-html/lib/index.js:253:27)
    at element (node_modules/.pnpm/hast-util-to-html@9.0.3/node_modules/hast-util-to-html/lib/handle/element.js:78:25)
    at one (node_modules/.pnpm/zwitch@2.0.4/node_modules/zwitch/index.js:108:17)

Expected behavior

No error is thrown or I can allow undefined values on attributes when stringifying

Actual behavior

Crashes when type is bogus value

Affected runtime and version

node@20.17.0

Affected package manager and version

pnpm@9.4.0

Affected OS and version

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Nov 18, 2024
@wooorm
Copy link
Member

wooorm commented Nov 18, 2024

Hi!

  • login is not a valid value for type on button — do not write incorrect HTML.
  • when you post code, remove everything that is not needed. Remove all the fields of all the options you do not needed, remove all the plugins you do not need, please, thanks.
  • can you please post version numbers of all the things? and make sure they are up to date?

@albinekb
Copy link
Author

albinekb commented Nov 18, 2024

Thanks for getting back so quickly!

After digging more I see that this package is not the source of the issue, opened an issue over there instead: syntax-tree/hast-util-from-html#8
Repro here: https://github.com/albinekb/hast-unknown-node-repro/blob/main/index.ts

login is not a valid value for type on button — do not write incorrect HTML.

Sadly I'm not the author of the HTML thats being parsed, not in my control. I expect the HTML parsing to not break if there's non-standard properties.

when you post code, remove everything that is not needed. Remove all the fields of all the options you do not needed, remove all the plugins you do not need, please, thanks.

I apologize for the rushed issue. Now added reproduction and found a fix.
Opened a PR

can you please post version numbers of all the things? and make sure they are up to date?

The issue in the end has already been fixed in hastscript@9.0.0

Adding this to my package.json fixes the issue 🎉

"pnpm": {
  "overrides": {
    "hast-util-from-parse5@8.0.1>hastscript": "9.0.0"
  }
}

Copy link

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

@wooorm
Copy link
Member

wooorm commented Nov 19, 2024

Released in hast-util-from-parse5@8.0.2, thank you for working on this!

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

No branches or pull requests

2 participants