Skip to content

bug: boolean attributes in form-associated components parsed wrongly #6319

Open
@annam002

Description

@annam002

Prerequisites

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.

The component:

@Component({
  tag: 'test-checkbox-form-associated',
  shadow: true,
  formAssociated: true,
})
export class TestCheckboxFormAssociated {
  @AttachInternals() internals: ElementInternals;

  @Prop() disabled: boolean | undefined = undefined;

  componentWillLoad() {
    if ('setFormValue' in this.internals) this.internals.setFormValue('');
  }

  render() {
    return (
      <label>
        <input type="checkbox" disabled={this.disabled} /> checkbox
      </label>
    );
  }
}

When using it with
<test-checkbox-form-associated disabled="false"></test-checkbox-form-associated>

this results in this HTML

<input type="checkbox" disabled="">

Expected Behavior

It works like before.

System Info

Stencil: 4.35.1 🦄
  TypeScript: 5.5.4
      Rollup: 4.34.9
      Parse5: 7.2.1
      jQuery: 4.0.0-pre
      Terser: 5.37.0

Steps to Reproduce

check out example repo and do npm run start

Code Reproduction URL

https://github.com/annam002/stencil-properties-bug

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within StencilHelp Wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions