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

fix: allow member access on directives #9462

Merged
merged 4 commits into from
Nov 15, 2023

Conversation

paoloricciuti
Copy link
Member

This closes #9445

What i've done is update the parser so that it splits the directive on . and reconcatenate them with [''] so that basically

nested.access becomes nested['access']. It seems to work fine but i leave the decision to you to see if this is actually the best approach.

Svelte 5 rewrite

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-4 and not main.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Nov 15, 2023

🦋 Changeset detected

Latest commit: 5cf47d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

Copy link

vercel bot commented Nov 15, 2023

@paoloricciuti is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@dummdidumm
Copy link
Member

dummdidumm commented Nov 15, 2023

I think I'd prefer it if we adjust the code inside template.js (or whereever it lives) instead to handle it at the point where the $.action code is generated. The AST should stay as close to what was actually written as possible to not affect validation etc.

@paoloricciuti
Copy link
Member Author

paoloricciuti commented Nov 15, 2023

I think I'd prefer it if we adjust the code inside template.js (or whereever it lives) instead to handle it at the point where the $.action code is generated. The AST should stay as close to what was actually written as possible to not affect validation etc.

That's were I started to look...should I move the same logic there?

Also by moving it there you actually need to add it to every directive that can accept a member access

@dummdidumm
Copy link
Member

Which ones do? All of them?
Yes, we maybe need to apply it to all of them, but having a reusable function should make this easy.

@paoloricciuti
Copy link
Member Author

Which ones do? All of them? Yes, we maybe need to apply it to all of them, but having a reusable function should make this easy.

Ok moving them there...not all of them in theory. Just updating the tests now and pushing again

@paoloricciuti
Copy link
Member Author

@dummdidumm i moved the tests to snapshots now is that the right place? Also in theory the snapshot for the server is not needed, there's a way to exclude that?

@dummdidumm
Copy link
Member

dummdidumm commented Nov 15, 2023

In runtime-legacy and runtime-runes we have a skip_if_ssr flag, you could implement a similar mechanism into the snapshot test suite.
Btw the test should also check for something like a.string-property which the issue is about

@paoloricciuti
Copy link
Member Author

In runtime-legacy and runtime-runes we have a skip_if_ssr flag, you could implement a similar mechanism into the snapshot test suite. Btw the test should also check for something like a.string-property which the issue is about

Uh defintely

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dummdidumm dummdidumm merged commit 6f3dc04 into sveltejs:main Nov 15, 2023
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Svelte 5: Actions from object properties are not properly escaped
2 participants