You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: boolean attributes in form-associated components parsed wrongly #6319
I have searched for existing issues that already report this problem, without success.
Stencil Version
4.35.1
Current Behavior
I am trying to upgrade to Stencil 4.35.1 from Stencil 4.23.0. In components that are form-associated the boolean properties now behave differently than before. They cannot be set to false anymore by using the property.
In a component like below, the checkbox cannot be set to disabled by the user of the web component anymore. This was working fine in Stencil 4.23.0.
From what I understand, you changed the behaviour to be compliant to the HTML standard. But this is a breaking change: users of our components now have to change from setting disabled="false" to removing the disabled-attribute. And if you want to comply to the standard, why do you only do it to form-associated components? they now behave differently than non-form-associated ones, which is wildly confusing.
Setting disabled="false" is the same as setting disabled="true". The fact that Stencil allowed to set negative boolean flags as properties has been a bug and we should clean this up.
Out of interest (genuine question) - if you removed the ability of Stencil to set bool=“false” how would one set a boolean (via attribute) whose default is “true” which does not necessarily reflect?
I realise the standard says “you just can’t” but is that acceptable?
Plus I think I’m right in saying that the standard doesn’t seem consistent regarding aria attributes?
The point is that you cannot set the property to false like before and this is a breaking change. We cannot upgrade now because it would break things for our users.
What I also don't understand: why was this behaviour only changed for form-associated components and not in general for all boolean properties?
Regarding the handling for form-ass. elements: I would recommend to be as near to the standard as possible. Even if we think its weird. I am sure there was an discussion about that. If not, the standard should be changed. So for me its acceptable and Stencil implements the standard 1:1.
The change itself is a breaking change. True. Maybe just release it as a major?!
Not sure about not setting false booleans at all. This topic is not necessarily related to this one, right? Just jumped into the standard.. there is a warning about true/false on boolean attributes: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes "The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether."
--> so I also would go this way and what @christian-bromann said. Having "booleanAttr=false" on a stencil element, stencil should remove this attr automatically. Makes sense to me.
@annam002 I'm going to close this one out as I don't think we're going to roll back this change (sorry - I know that's not what you're looking for).
Removing stencil's weird behaviour around string "false" is probably the best way forward long-term but I do realise this is a breaking change so should not have been in a patch / minor release.
Activity
annam002 commentedon Jun 27, 2025
Was probably introduced with this PR: #6280
danyball commentedon Jun 27, 2025
This is not a bug, its a feature! You can read that in the html standard. Also see #5461
annam002 commentedon Jun 27, 2025
From what I understand, you changed the behaviour to be compliant to the HTML standard. But this is a breaking change: users of our components now have to change from setting disabled="false" to removing the disabled-attribute. And if you want to comply to the standard, why do you only do it to form-associated components? they now behave differently than non-form-associated ones, which is wildly confusing.
christian-bromann commentedon Jun 27, 2025
Setting
disabled="false"is the same as settingdisabled="true". The fact that Stencil allowed to set negative boolean flags as properties has been a bug and we should clean this up.johnjenkins commentedon Jun 27, 2025
Out of interest (genuine question) - if you removed the ability of Stencil to set bool=“false” how would one set a boolean (via attribute) whose default is “true” which does not necessarily reflect?
I realise the standard says “you just can’t” but is that acceptable?
Plus I think I’m right in saying that the standard doesn’t seem consistent regarding aria attributes?
christian-bromann commentedon Jun 27, 2025
I would advocate for a best practice where you would use a negation attribute, e.g.
to set it to false, you would just do
<my-component no-my-bool />. This could be something that Stencil could do automatically.Thoughts?
annam002 commentedon Jun 28, 2025
The point is that you cannot set the property to false like before and this is a breaking change. We cannot upgrade now because it would break things for our users.
What I also don't understand: why was this behaviour only changed for form-associated components and not in general for all boolean properties?
christian-bromann commentedon Jun 30, 2025
@danyball any thoughts here?
danyball commentedon Jul 25, 2025
Thanks Christian for pinging me.
Regarding the handling for form-ass. elements: I would recommend to be as near to the standard as possible. Even if we think its weird. I am sure there was an discussion about that. If not, the standard should be changed. So for me its acceptable and Stencil implements the standard 1:1.
The change itself is a breaking change. True. Maybe just release it as a major?!
Not sure about not setting false booleans at all. This topic is not necessarily related to this one, right? Just jumped into the standard.. there is a warning about true/false on boolean attributes: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes "The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether."
--> so I also would go this way and what @christian-bromann said. Having "booleanAttr=false" on a stencil element, stencil should remove this attr automatically. Makes sense to me.
johnjenkins commentedon Oct 10, 2025
@annam002 I'm going to close this one out as I don't think we're going to roll back this change (sorry - I know that's not what you're looking for).
Removing stencil's weird behaviour around string "false" is probably the best way forward long-term but I do realise this is a breaking change so should not have been in a patch / minor release.
Solutions / moving forward:
falsedefaults tofalsenot undefined:@Prop() disabled: boolean | undefined = undefined;>@Prop() disabled: boolean = false;true) use the@AttrDeserializedecorator:Now
<my-thing disabled="false">works as it used to