-
- Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: use setAttribute for spellcheck and translate #12734
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
fix: use setAttribute for spellcheck and translate #12734
Conversation
🦋 Changeset detectedLatest commit: c5ff21c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| I had to wonder whether there are other similar attributes, namely enumerated attributes corresponding to boolean properties, and so I updated the comment to reflect what I learned. It turns out, though, that the list of global enumerated attributes with div = document.createElement('div'); div.translate; // true div.setAttribute('translate', 'false'); div.translate; // true div.setAttribute('translate', 'no'); div.translate; // false div.translate = true; div.setAttribute('translate'); // 'yes'So in other words it seems we don't want to include <script> let a = { translate: false }; let b = { translate: 'no' }; </script> <div translate={false}>...</div> <div translate="no">...</div> <div {...a}>...</div> <div {...b}>...</div>We're currently wrong (in the I also think that we should probably tell users (at compile time, where attribute values are known statically, and at runtime otherwise) if they set an enumerated attribute to something other than one of the possible values. Also: |
Rich-Harris left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
countermanding the approval until we can figure out the correct behaviour
| Uhm...i think the reason why this is not working for the last two bits is because we are only using |
Ok no, different reason: we always call
I'm also wondering if there's a way to reuse more logic between |
| For the moment i've implemented the first option because i think if the user passes an actual boolean it likely means the respective boolean parameter ( Btw if you look at the linked issue there are a bunch of those properties including contenteditable but by testing it doesn't seems the browser is following |
| We have a list of attributes somewhere which we set through the corresponding property instead. Could we use that instead? |
I think when it's in string form we should stick to what the dom does...but I think people also expect to be able to use booleans just like they do with
Where can I find such list? |
| Hello. I have a question: Will this correct the other attributes as well? For example, |
If you look at comments in the issue most of the list there is actually already fine. |
| Thanks for dropping by. It is a good thing that most are already fine. The list, however, is an incomplete list as the author states, and I have an instance at work where it adds |
| Opened #13327 with the approach outlined above. I don't see any reason we shouldn't Do The Right Thing when encountering both Out of curiosity I checked to see what React does. They do the correct thing for
...so much for 'we make you use |
Wait was this doing the wrong thing? I was under the impression that this was already doing the right thing that's why i didn't touch it |
| But regardless...if you found a solution that is better let's go with it...closing. |
Svelte 5 rewrite
Closes #12664
Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (
main).If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is
svelte-4and notmain.Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.Tests and linting
pnpm testand lint the project withpnpm lint