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

[BUG]: Checkbox trait doesn't remove attribute when unchecked #943

Closed
nojacko opened this issue Mar 9, 2018 · 4 comments
Closed

[BUG]: Checkbox trait doesn't remove attribute when unchecked #943

nojacko opened this issue Mar 9, 2018 · 4 comments
Labels

Comments

@nojacko
Copy link
Contributor

nojacko commented Mar 9, 2018

When html attributes are true or false, the should either exist or not exist.

For example, required. This don't have a value in HTML5.

  • Valid (not required):<input type="text">
  • Valid (required): <input type="text" required>
  • Invalid (not required):<input type="text" required="false">
  • Invalid (required):<input type="text" required="true">

When the HTML grapes is then rendered outside Grapes and the input is checked if it's required, this fails as Chrome always returns true is the required attributes is set... regardless of the value.

I've been looking into this myself but not figure it out yet but it looks like Components needs a removeAttribute function to handle this.

Sorry, but in a rush, so I'll provide fiddle on Monday...

@artf artf closed this as completed in 9a71368 Mar 10, 2018
@nojacko
Copy link
Contributor Author

nojacko commented Mar 12, 2018

@artf Thanks for the quick solution but it doesn't appear to work. Both inspecting the Grapes source and calling getHtml() return required="true" and required="false". I'm guessing because the attribute is a boolean value represented as a string.

I will where I can but, unfortunately, I'm on an unusual tight schedule for the GDPR rules coming in.

@artf
Copy link
Member

artf commented Mar 14, 2018

probably the same as #912 (comment)

@mikereem
Copy link

mikereem commented May 2, 2019

I think commit 9a71368 is not enough. It writes boolean attributes without their values to the html output fine. But when the output is read again by the editor, then the boolean attributes are not initialized. If the boolean attribute was shown in the html (which means the value is true), then the editor initializes this attribute with value: "" and not true.

@lock
Copy link

lock bot commented May 5, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label May 5, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants