-
Notifications
You must be signed in to change notification settings - Fork 150
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
phx-value-* shows inconsistent behaviour with LiveView #512
Comments
Is there a difference in the HTML Surface produces (0.5 vs 0.6)? |
yes 0.5 would render |
Same issue here. I wanted to note that if the value of |
I can confirm it's a regression. Working on the fix now. |
This has been fixed in 5c53916. I'll release Thanks! |
@msaraiva there's another case where this is still happening, and also on v0.6.1. I am using In essence, these two lines have different output:
which are rendered to, respectively:
As you can see above, one changes underscore to dashes, the other does not. This is happening when using Link component but as you can also see above when using :attrs directly. |
I was poking around the source code and I am unsure how this should be fixed, and if at all. The behavior currently is confusing and ideally I'd like to see something like this instead:
But I am unsure how to do it without special handling for the attribute that has name of :"phx-vallue-" or :"phx_value_". @msaraiva I can try implementing the above but do you think the above behavior is desired, plus are you ok with special case for "phx-value-*" attribute? |
I had another pass at the issue and what seems to be the easiest solution for me is to switch to using String as the key, and map instead of keyword keys when passing the "phx-value-" attribute name, and it seems to work as expected when used directly:
and
both preserve underscore, because of how that's handled in here The problem still remains when using with pre-defined components. They take which would be also acceptable solution for now. I see now two possibilities to solve this problem:
Or maybe something entirely different. @msaraiva your thoughts would be appreciated. |
Hi @hubertlepicki! I agreed this is confusing and to be honest, I think the best option would be to never do any conversion, however this is the way how Phoenix/LV handles attributes so it's better to keep it consistent.
I guess |
@msaraiva sorry for the late response, I had some sick downtime last week, I agree. I'll add a feature-request and possibly start working on it. |
There seems to be a regression in version 0.7, see #562. |
Describe the bug
After upgrading surface from 0.5 to 0.6
phx-value-*
bindings changed in how they behaved. This is not documented in the changelog's breaking changes and I cant find the commit that introduced the behavioural change.How to reproduce it
On Surface 0.5 this matches:
On Surface 0.6 this doesn't match because
some_value
is nowsome-value
The behavior you expected
LiveView itself does not change the variable name. It is ok to do so but this should be documented then in a prominent place and should be mentioned as breaking change.
Your Environment
Surface: v0.6.0
LiveView: v0.16.4
Elixir: v1.12.3
The text was updated successfully, but these errors were encountered: