purescript-halogen / purescript-halogen-vdom

An extensible virtual-dom library for PureScript.
Apache License 2.0
58 stars 25 forks source link

DOMException thrown when switching between file/text input types #28

Open garyb opened 5 years ago

garyb commented 5 years ago

I need to come up with a small reproduction case for this, but as an example of the error:

Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
    at ./output/Halogen.VDom.Util/foreign.js.exports.unsafeSetAny (http://localhost:3000/index.js:87081:14)
    at http://localhost:3000/index.js:86101:21
    at Object../output/Halogen.VDom.Util/foreign.js.exports.diffWithKeyAndIxE (http://localhost:3000/index.js:87156:15)
    at Step.patchProp [as value2] (http://localhost:3000/index.js:86133:40)
    at Object.step (http://localhost:3000/index.js:86664:14)
    at Step.patchElem [as value2] (http://localhost:3000/index.js:86273:43)
    at Object.step (http://localhost:3000/index.js:86664:14)
    at onThese (http://localhost:3000/index.js:86288:43)
    at Object../output/Halogen.VDom.Util/foreign.js.exports.diffWithIxE (http://localhost:3000/index.js:87124:17)
    at Step.patchElem [as value2] (http://localhost:3000/index.js:86297:36)

This is from a form where we have a switchable section, and so patching is reusing an input as both a password input and as a file input. Entering a value in the password field then switching back and forth resulted in the error.

I fixed it by keying the inputs so they would definitely not be shared, but it seems like something we should perhaps handle during patching rather than allowing it to explode at runtime.

natefaubion commented 5 years ago

Fixing this would probably require having a separate diff process for input elements and their attributes.