-
-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeating DOM (input[type=file] has a ~readonly value, causing crashes) #1956
Comments
After toying around, I'm finding weirder things than even that... (pen, as minimal as I can get it)
Super odd... |
I moved it to flems for toying around with Mithril itself, and I get this error every first time I click the button after picking a file (look at the real console, flems only shows the last one that's been thrown):
Not sure how that error ends up confusing Do we consider that a user error ( Edit: reduced even more. Edit2: @rbt you can delete line 79 ( Edi3: |
@pygy Good spot! (I totally overlooked that part...)
I'd add this as another exception, provided it's the same string. If it's different, it's a user error, but if it's still the same string, we should accept it, so it still works with the common two-way binding pattern: m("input[type=file]", {
value: this.value(),
onchange: m.withAttr("value", this.value)
}) |
We'd also need to special case the empty string (to reset the value)... |
@pygy: Yep. Prior to submitting the ticket I changed my code to check the field type and skip setting the value for "file" fields. It does indeed solve the issue. For a Mithril fix, I'd be perfectly happy if it threw an error. |
Not a blocker for v2, but it's something I want to get fixed soon. |
The root cause is a lot more subtle than it looks: Mithril doesn't know how to deal with errors during rendering at all, much less errors from DOM manipulations. It stems from This is blocked on #2273. |
Note: this doesn't actually provide proper error handling. This just kicks the can down the road by addressing the file input as a one-off fix (since it's the only such DOM property I'm aware of that can throw on set).
Note: this doesn't actually provide proper error handling. This just kicks the can down the road by addressing the file input as a one-off fix (since it's the only such DOM property I'm aware of that can throw on set).
Note: this doesn't actually provide proper error handling. This just kicks the can down the road by addressing the file input as a one-off fix (since it's the only such DOM property I'm aware of that can throw on set).
Note: this doesn't actually provide proper error handling. This just kicks the can down the road by addressing the file input as a one-off fix (since it's the only such DOM property I'm aware of that can throw on set).
Note: this doesn't actually provide proper error handling. This just kicks the can down the road by addressing the file input as a one-off fix (since it's the only such DOM property I'm aware of that can throw on set).
On submission of the form with a file selected, the DOM repeats. I was attempting to make a progress bar for a file upload when this appeared.
Seems to be broken in both 1.1.3 and Next in both FireFox and Chrome.
The main issue seems to be the round-trip of e.target.value for a file selection box. I've run out of brainpower to simplify this further but it almost certainly could be.
Order of the elements also seems to matter. Putting new material (version string in this case) after the form doesn't seem to cause the repeat.
https://codepen.io/rbt123/pen/WEPdby
The text was updated successfully, but these errors were encountered: