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

No attribute value rendered as "true" #1852

Closed
jvmccarthy opened this issue Nov 16, 2018 · 1 comment
Closed

No attribute value rendered as "true" #1852

jvmccarthy opened this issue Nov 16, 2018 · 1 comment
Labels

Comments

@jvmccarthy
Copy link

I'd like to render an element attribute with an optional value. For example,

<div no-value></div>

However, svelte is rendering this with the value of "true",

<div no-value="true"></div>

If I add an empty string value, the rendering is as expected. This,

<div no-value=""></div>

renders as,

<div no-value></div>

I think the underlying call to setAttribute() should be a blank string if there is no value instead of true.

Svelte repl here. Inspecting the rendered output shows how without an attribute value, a value of "true" is rendered.

@jvmccarthy jvmccarthy changed the title Optional attribute value rendered as "true" No attribute value rendered as "true" Nov 16, 2018
@Ryuno-Ki
Copy link

IIRC that behaviour is valid for XHTML. Maybe Svelte is doing something here …
Only with HTML5 it became valid for an attribute to not have a value. That is, it's mere presence implied the value of true.

@Conduitry Conduitry added the bug label Jan 3, 2019
Conduitry added a commit that referenced this issue Jan 5, 2019
- compile unknown bare attribute names to setting the attribute to ""
- correctly stringify as bare attribute name in .innerHTML'd markup
Rich-Harris added a commit that referenced this issue Jan 13, 2019
Rich-Harris added a commit that referenced this issue Jan 13, 2019
Rich-Harris added a commit that referenced this issue Jan 13, 2019
better handling of bare attribute names in DOM mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants