Skip to content
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

v2: Remove the legacy attributes option #36

Open
patricknelson opened this issue Dec 5, 2023 · 0 comments
Open

v2: Remove the legacy attributes option #36

patricknelson opened this issue Dec 5, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@patricknelson
Copy link
Owner

patricknelson commented Dec 5, 2023

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 Move to Svelte 4 style custom element API, support prop type coercion #13 there will be no place to put it anyway (at least not for now).
  2. We can use Proxy (from Support context from custom element ancestors #10) and MutationObserver (from Add ability to automatically forward all attributes to props #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 Add ability to automatically forward all attributes to props #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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant