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

Using an action twice throws "same attribute" error #5516

Closed
pushkine opened this issue Oct 11, 2020 · 7 comments · Fixed by #5875
Closed

Using an action twice throws "same attribute" error #5516

pushkine opened this issue Oct 11, 2020 · 7 comments · Fixed by #5875
Labels
awaiting submitter needs a reproduction, or clarification

Comments

@pushkine
Copy link
Contributor

https://svelte.dev/repl/01a14375951749dab9579cb6860eccde?version=3.29.0

<script>
	function action(){}
</script>

<div use:action use:action />
Attributes need to be unique (5:16)
@peopledrivemecrazy
Copy link
Contributor

peopledrivemecrazy commented Oct 11, 2020

Do you want to have the same script run twice on the node?

@antony antony added the awaiting submitter needs a reproduction, or clarification label Oct 15, 2020
@niklasgrewe
Copy link

niklasgrewe commented Oct 18, 2020

@peopledrivemecrazy @antony I have a similar question: Is it possible to use an action twice on the same node? I have written a small animation function that looks something like this:

<div use:animate={{trigger: scrollY, opactiy: {start: 0, end: 200, from: 0, to: 1}}} />

It would be very helpful for me if I could use them several times on same element, so i can create in and out scroll animations.

@antony
Copy link
Member

antony commented Oct 18, 2020 via email

@voscausa
Copy link

You can use it twice like this:

<script>
	function action(){}
	const alias = action;
</script>

<div use:action use:alias />

@peopledrivemecrazy
Copy link
Contributor

You can use it twice like this:

<script>
	function action(){}
	const alias = action;
</script>

<div use:action use:alias />

This works great.

@Conduitry
Copy link
Member

As of 3.32.0, you can now have multiple instances of the same action - https://svelte.dev/repl/01a14375951749dab9579cb6860eccde?version=3.32.0

@peopledrivemecrazy
Copy link
Contributor

<script>
	let x = 0
	function action(){
		x+=1
	console.log(x)
	}
</script>

<div use:action use:action use:action use:action />

This works fine good job @pushkine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter needs a reproduction, or clarification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants