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

Unable format element's with properties type and value that aren't tagName: input #22

Closed
4 tasks done
matthewp opened this issue Jan 18, 2024 · 6 comments
Closed
4 tasks done
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on

Comments

@matthewp
Copy link

Initial checklist

Affected packages and versions

hast-util-raw@9

Link to runnable example

https://codepen.io/matthewp/pen/rNRmLLq?editors=1010

Steps to reproduce

This is enough to cause it

import {raw} from 'hast-util-raw'
import {h} from 'hastscript'

const tree = h('div', {'type':'number','value':'1'}, []);

const reformatted = raw(tree);

console.log(reformatted);

Note that if you replace div with input it works fine. I traced this back from an Astro bug which is reproducible at a higher level here: https://stackblitz.com/edit/github-qdnomy?file=src%2Fpages%2Findex.md . In that example the div comes into hast-util-raw as a "raw" node (I think), but I assume that it's the same underlying issue as in the reduced example.

Expected behavior

Should be reformatted with the properties as properties.

Actual behavior

Throws with: Cannot compile number node

Affected runtime and version

node@18 and Chrome

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

Astro

@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 Jan 18, 2024
@ChristianMurphy
Copy link
Member

Hey @matthewp! 👋
Sorry you ran into a spot of trouble.
It sounds a lot like you are running into syntax-tree/hastscript#21 please see the discussion there

@matthewp
Copy link
Author

It does seem that way, @ChristianMurphy, is it better to close this one in that case?

@matthewp
Copy link
Author

That's a higher-level issue, I think this is the right place for this one.

@matthewp
Copy link
Author

Ah no, it's with hastscript, that's what's pushing it down into children.

@ChristianMurphy
Copy link
Member

It is better to close this.

Throws with: Cannot compile number node

number is not an MDAST node type https://github.com/syntax-tree/mdast#readme
Handling invalid HTML is not an expectation/requirement of the formatter.

Generate valid HTML for the formatter to work.


Where you are generating the AST make sure it is valid.
If you are using hastscript this is exactly syntax-tree/hastscript#21
If something else is generating the AST, that could be discussed further there.

This comment has been minimized.

@ChristianMurphy ChristianMurphy added the 👀 no/external This makes more sense somewhere else label Jan 18, 2024
@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jan 18, 2024
@ChristianMurphy ChristianMurphy closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants