Skip to content

bug: Incorrect value update when switching falsy values for a prop typed as any. #6572

@SaiGovardhana

Description

@SaiGovardhana

Prerequisites

Stencil Version

v4.32.0

Current Behavior

When a component property changes between different falsy values, the DOM may not update, leaving the rendered output out of sync.

Expected Behavior

The dom should be in sync the currently value of the prop.

System Info

Steps to Reproduce

Setup:
A component with a prop as any and and rendering an input with the prop binded to the value

@Component({
  tag: 'cmp-input-wrapper',
  shadow: true,
})
export class FalsyDemo {
  @State() value: any = 0;

  render() {
    return (
      <Host>
        <input value={this.value} />
      </Host>
    );
  }
}

Steps:

  • Now set value to an empty string
  • Now set value to 0

Code Reproduction URL

https://github.com/SaiGovardhana/stencil-starter

Additional Information

We have a numeric input wrapper component where the value type is defined as any, allowing consumers to pass either a string or a number depending on their use case (for example, to preserve leading zeros). Currently, we are handling this situation when switching between falsey values by performing preliminary checks and then converting the value to a string with toString().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions