Skip to content

Race condition between native browser state and VDom #950

Open
@Fresheyeball

Description

@Fresheyeball

When hitting a checkbox, there is race condition where the native browser state will set the checkbox to checked: true and Snabbom fails to set checked: false. Here is a minimal complete example

var inBetween; // holds the intermediate vnode

const vnode1 = hh('div', {}, [ // vnode1 has the div with 2 checkboxes set to false
  hh('input', { on : { change : () => patch(inBetween,vnode2)}, // when the first checkbox is changed, we change to vnode2
                props : { checked : false, type : "checkbox" } }, []),
  hh('input', { props : { checked : false, type : "checkbox" } }, [])
])

const vnode2 = hh('div', {}, [
  hh('input', { props : { checked : false, type : "checkbox" } }, []) // vnode2 has the div containing 1 checkbox set to false
])

inBetween = patch(container, vnode1); // works as expected

Reproduction

You can see this bug occur live here: https://plnkr.co/edit/TyvcMBT0F3TQ5YDq

document.getElementsByTagName("input").length == 2
document.getElementsByTagName("input")[0].checked == false
document.getElementsByTagName("input")[1].checked == false
  1. Click the first checkbox

Expected Result

document.getElementsByTagName("input").length == 1
document.getElementsByTagName("input")[0].checked == false

Actual Result

document.getElementsByTagName("input").length == 1
document.getElementsByTagName("input")[0].checked == true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions