Skip to content

Conversation

@LostKobrakai
Copy link
Contributor

@LostKobrakai LostKobrakai commented Nov 11, 2025

This breaks tests around wildcard behaviour, which however I'm not sure I agree them testing behaviour I'd expect.

Closes #4049

@SteffenDE
Copy link
Collaborator

I agree that the current behavior is confusing. I'm only worried that some people might already rely on this behavior, so maybe we need to make it opt in, like JS.ignore_attributes(attrs, track_removed: true) 🤔

@SteffenDE
Copy link
Collaborator

fwiw I was thinking about a phx-track-attributes that would keep client-side changes to attributes and still allow patches from the server for any untouched attribute. I think we should be able to make that work by changing how morphdom morphs attributes, but I didn't find the time to actually look how feasible it would be.

@LostKobrakai
Copy link
Contributor Author

LostKobrakai commented Nov 11, 2025

Hmm. That's a good point about tracking client side changes. I could probably work around the issues I'm seeing by using js commands to alter attributes instead of using direct dom manipulation. I still don't think ignore attributes works in an expected manner.

How do you feel about adding this check only for non-wildcard ignores? Imo the fact that removing open is caught/ignored, but adding open is applied to the DOM to me looks like a bug not intended behaviour.

@SteffenDE
Copy link
Collaborator

It's tricky. I think if we change it, we should change it for all attributes and not handle wildcards differently. I'll need to think about it for a bit.

SteffenDE added a commit that referenced this pull request Nov 13, 2025
Adds `phx-update="track-attributes` and `phx-track-attributes` attribute
where the first one tracks attributes on the whole subtree and the second
one only for the element that set the attribute.

Using this makes LiveView keep clientside changes until a server overrides
an attribute value with a new one. This is useful when clientside libraries
rely on attributes they set, but `phx-update="ignore"` is too much.

This is a proof of concept, I'm not sure we actually want to go with
this. For simplicitly, I vendored morphdom into the repo. The important
change there is a new `proxyFromEl` callback + changes to morphAttrs.

Relates to: #4049
Relates to: #4050 (comment)
@SteffenDE
Copy link
Collaborator

Let's go ahead with this, please just adjust the failing test :)

@LostKobrakai LostKobrakai marked this pull request as ready for review November 14, 2025 16:50
@SteffenDE SteffenDE merged commit d1fa20a into phoenixframework:main Nov 14, 2025
8 checks passed
@SteffenDE
Copy link
Collaborator

🙌🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore attributes not working for unset boolean attribute

2 participants