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

Component event and prop names too permissive #5903

Closed
pushkine opened this issue Jan 19, 2021 · 11 comments
Closed

Component event and prop names too permissive #5903

pushkine opened this issue Jan 19, 2021 · 11 comments

Comments

@pushkine
Copy link
Contributor

pushkine commented Jan 19, 2021

Event and prop names accept all characters but space, quotes, > and =

<Component on::::\\\\!!!}}]]{{{function(){return`hello_world`}}{]]])(((\ \\````::\**\{{{}}}}}}<<<<<<Component />
component = new Component({
	props: {
		"\\\\````::\\**\\{{{}}}}}}<<<<<<Component": true
	}
});

component.$on(":::\\\\\\\\!!!}}]]{{{function(){return`hello_world`}}{]]])(((\\", 
/*function_return_hello_world_handler*/ ctx[0]);

https://svelte.dev/repl/8bff2976db80403db1affa9138c3e8dd?version=3.31.2

@dummdidumm
Copy link
Member

Agree with that. From a tooling perspective it would be ideal to only allow alphanumeric characters and $_ and maybe -

@Conduitry
Copy link
Member

Is this actually causing a bug, or is it just unsightly?

@dummdidumm
Copy link
Member

dummdidumm commented Jan 19, 2021

From a tooling perspective it causes some problems because JSX/TSX, which code is transformed to for intellisense features, is more restrictive, but I've not yet encountered an actual bug. So from my point of view it would be more of a "more well defined" thing.

@stale
Copy link

stale bot commented Jun 26, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Jun 26, 2021
@dummdidumm
Copy link
Member

I still think this would be good to make more strict. It would make tooling easier. Strictly speaking it's probably a breaking change though.

@stale stale bot removed the stale-bot label Jun 26, 2021
@stale
Copy link

stale bot commented Dec 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Dec 23, 2021
@dummdidumm
Copy link
Member

Thinking about this differently now. Still would be cool but many libraries take advantage of the more permissive nature of props and events and added things like - to their prop names. Also some libraries work around current limitations of event bubbling by using special characters that are not ! to simulate event modifiers.

@dummdidumm
Copy link
Member

Now thinking that it's not worth the hassle - the language tools argument I brought up back in the day is no longer relevant.

@Rich-Harris
Copy link
Member

we decided to not worry about this. it is a potential footgun, but it's also a potential escape hatch, and escape hatches should be left unlocked

@Rich-Harris Rich-Harris closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2024
@Malix-Labs
Copy link

Malix-Labs commented Aug 22, 2024

What would be an example where such escape hatches would be required?

@Rich-Harris
Copy link
Member

The nature of escape hatches is that it's hard to predict when you need them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants