So, we’re migrating away from AlpineJS to web components (Lit library) integration with LiveView and it’s been a very pleasant experience so far.
Having a relatively minor issue with how LiveView expects to mark ignored attributes though (via phx-mounted={JS.ignore_attributes([ ..])} because now I need to wrap each custom element into a Phoenix function component only to encapsulate this phx-mounted attribute, a wrapping that would be otherwise totally redundant.
Is there any chance there could be another method of achieving the same effect added (e.g. phx-ignore-attrs or a liveSocket api API call). I did try to invoke window.liveSocket.js().ignoreAttributes( el, [ 'foo', 'bar']) and it didn’t crash but unfortunately, it didn’t produce the desired result either.
Thanks
CLARIFICATION: the ignoreAttributes was done from custom element’s connectedCallback
Ok.. so it’s not a bug because it works when invoked from the mounted() of a hook attached to the custom element, but then there’s still this redundancy - the custom element’s own JS + the hook’s JS + the phx-hook attribute.
Can it be made to work when called from outside of the hook too, like from connectedCallback which is already a standard for custom elements?
Now that I’m using it, I wonder which one will prevail if the custom element user (still me, but forgetting doing this at a later point in time) declares a phx-hook for the custom element in the template where it’s being used?
I could console.warn or throw if the phx-hook attribute exist, but I’m still curious about the actual dynamics and whether it’s even smart to rely on it (given a possibility for the behavior to maybe change over time).
Again, asking because LLMs are not providing a 100% certainty answer.