Skip to content

Spreads: Property new/old value equality check isn't done against the DOM value #2016

@AFatNiBBa

Description

@AFatNiBBa

Describe the bug

If, on the playgrround example, the line containing the spread gets removed, the value property of the input field will be assigned as follows:

_$effect(() => _el$.value = get());

This will have the desired effect.
If the spread line doesn't get removed the value property will be setted like this:

_$spread(_el$, _$mergeProps({
  get value() {
    return get();
  }
}, {}), false, false);

The spread() function sets properties of elements using assignProp(), which won't change the value of the property on the actual element if its old value is the same as the new one.
The problem is that if we type "unallowe" and then add a "d", the signal will remain with "unallowe" while the input field will contain the "d" too.
This happens because the value property of the actual element contained the "d" because of the user interaction, but the solid props used to create that input field still only contained "unallowe"; so when the signal was updated with the same value ("unallowe"), assignProp() believed that there were no changes.
I think this line should not return if value is different from the one contained in node

Notice that there's a workaround for this problem, you just need to set the prop:value attribute instead of the value one

Your Example Website or App

https://playground.solidjs.com/anonymous/6e6f686b-e624-49c5-b5cb-f445207883f4

Steps to Reproduce the Bug or Issue

  1. Type "unallowe" on the input field
  2. Type "d", the new letter will be shown but the actual value will remain the same
  3. Type another character, the actual value will start being updated again

Expected behavior

When typing "d" (2nd step), nothing should've turned up in the first place

Screenshots or Videos

No response

Platform

(Not needed)

  • OS: Windows
  • Browser: Edge
  • Version: 120.0.2210.77

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions