patricknelson/svelte-retag

v2: Remove the legacy `attributes` option

Opened this issue · 0 comments

Describe the problem

This is a legacy of forking from svelte-tag and is no longer necessary since:

  1. Svelte v4 already automatically forwards all attributes to props by default and doesn't offer any API to disable or configure this per se (note that this is different from prop reflection, where changes in prop values are updated back to the attributes in the DOM). Also, with #13 there will be no place to put it anyway (at least not for now).
  2. We can use Proxy (from #10) and MutationObserver (from #34) together to dynamically infer the attributes to watch for changes. The attributes option only existed out of necessity historically because it simply wasn't possible at the time to automatically know early enough (statically) without breaking things which props existed on the component without requiring the user to tell you what they were. See #34 for more.

Svelte is able to do this more easily since it's a compiler, so the magic ✨ noted above is still required for us to perform this. Since this is a breaking change, this must be done in v2 and not in v1.

NOTE: See outstanding TODO: ISSUE-36 items.

Describe the proposed solution

Remove attributes from the options array and the associated observedAttributes/attributeChangedCallback methods in favor of the MutationObserver technique utilized in #34.

Alternatives considered

Keep the feature around, but instead find another way to define svelte-retag specific features which do not fit into the Svelte 4 style options syntax being built in #13. While this is feasible, it's not planned so this would be additional related (but separate) work from this particular ticket.

Importance

necessary due to #13 at the moment (see "Alternatives considered" and point 1 at the top).