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

Empty Value Attribute Handling #75

Closed
NiklasPor opened this issue Jun 15, 2021 · 3 comments · Fixed by #89
Closed

Empty Value Attribute Handling #75

NiklasPor opened this issue Jun 15, 2021 · 3 comments · Fixed by #89

Comments

@NiklasPor
Copy link

Hi all, great package, love it so far 🚀

I'm currently struggling with one problem tho: The HTML attributes that have no specific value, actually automatically get transformed to have a value of their own key.

I think this transformation is kinda weird, especially since the current HTML standard is specifying that the value of an empty attribute is actually an empty string, not a string that matches the name of the attribute:

image
https://html.spec.whatwg.org/multipage/syntax.html#attributes-2

Additionally, it breaks the behavior of some JS / HTML frameworks, which is a pity. Here's a quick example without any plugins installed:

Input

<div a b c="c"></div>

Expected

<div a b c="c"></div>

Output

<div c="c" a="a" b="b" other="other"></div>

I'd also be open to contributing and fixing this if it would be appreciated.

Kind regards
Niklas

@Scrum
Copy link
Member

Scrum commented Jun 16, 2021

I'd also be open to contributing and fixing this if it would be appreciated.

@NiklasPor Hello, we appreciate any contribution that benefits the package, feel free to do so.

This task is more likely to be posthtml-render (I will transfer the task to this package) i.e. it is there that it is necessary to enumerate a list of single attributes and set the corresponding values.

@NiklasPor
Copy link
Author

@Scrum Hm, when I debugged this I also received {a: 'a'} as the attribute object for a tag like this <div a></div>.

So I think this is mainly part of the parser, but also requires change inside the renderer.

@Scrum
Copy link
Member

Scrum commented Jun 17, 2021

@NiklasPor strange, I see a different parser result https://runkit.com/scrum/60caf310c34719001bbc7c06

lyfeyaj pushed a commit to lyfeyaj/posthtml-parser that referenced this issue Feb 7, 2022
@Scrum Scrum linked a pull request Feb 25, 2022 that will close this issue
@Scrum Scrum closed this as completed in #89 Feb 25, 2022
Scrum added a commit that referenced this issue Feb 25, 2022
feat: add `recognizeNoValueAttribute` option for issue #75
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 a pull request may close this issue.

2 participants