Issue #943💬 AnsweredOpened March 9, 2018by nojacko0 reactions

Checkbox trait doesn't remove attribute when unchecked

Quick answerby nojacko

@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...

Read full answer below ↓

Question

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): Valid (required): Invalid (not required): Invalid (required): 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 fidd...

Answers (3)

nojackoMarch 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 unu...

mikereemMay 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...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.