preact icon indicating copy to clipboard operation
preact copied to clipboard

Undefined can clear checked and value properties for custom elements

Open objerke opened this issue 3 years ago • 1 comments

This pull requests makes it possible to reset the value and checked properties on a custom element, by passing undefined as a prop value. Tests are added with the new behavior.

This is a follow up on https://github.com/preactjs/preact/pull/2472 which slightly altered the behavior of https://github.com/preactjs/preact/pull/2465 in terms of undefined values. Currently an undefined value is never set for the value and checked properties.

it(`should clear existing 'value' property with ""`, () => {
    render(<test-component value={{ foo: 'bar' }} />, scratch);

    render(<test-component value={undefined} />, scratch);

    expect(scratch.querySelector('test-component').value).to.equal("");
});

We are using preact to render custom elements that uses properties to pass down data. The value can be cleared as a way to indicate an indeterminate state. I think it feels natural to allow the value and checked properties to function as any other property when it comes to custom elements.

objerke avatar Nov 23 '22 10:11 objerke

📊 Tachometer Benchmark Results

Summary

A summary of the benchmark results will show here once they finish.

Results

The full results of your benchmarks will show here once they finish.

tachometer-reporter-action v2 for Benchmarks

github-actions[bot] avatar Nov 23 '22 10:11 github-actions[bot]