You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add `JS.ignore_attributes`
Sometimes it is useful to ignore updates to specific attributes. One
famous example is the "new"-ish HTML `dialog` element that relies on
an `open` attribute to determine if it is open or closed. The same
applies to `details` elements. Importantly, when opened by a user, the
browser sets this attribute by itself and LiveView should not overwrite
it on patches, otherwise it would accidentally close it again.
Previously, the recommended way to handle such cases was to add a function
to the `onBeforeElUpdated` dom option of the `liveSocket`. This is
cumbersome though and especially for libraries leads to more friction, as
more steps are necessary to install them.
Now, one can use `JS.ignore_attributes` in instead, for example:
```heex
<details phx-mounted={JS.ignore_attributes(["open"])}>
<summary>...</summary>
...
</details>
````
And then the details element will always retain the previous open state,
regardless of what the server does.
Relates to: #3741
Relates to: #2349
Relates to: #3574
* add test for wildcard
* accept single attribute
* fix precedence
* add ignoreAttributes to this.js()
0 commit comments