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

Default parameters in computed properties compiles incorrectly #274

Closed
coulson84 opened this issue Feb 1, 2017 · 2 comments · Fixed by #276
Closed

Default parameters in computed properties compiles incorrectly #274

coulson84 opened this issue Feb 1, 2017 · 2 comments · Fixed by #276

Comments

@coulson84
Copy link

Not sure if this is considered an anti-pattern in terms of using svelte but I had setup a computed property using a default value and it did not compile to what I was expecting it to

given a computed object as below

computed: {
  someProperty: (val1, val2 = 'defaulted') => val1 + val2 
}

Then applyComputations for the component has the following code present

if ( ( 'val1' in newState && typeof state.val1 === 'object' || state.val1!== oldState.val1) || ( 'undefined' in newState && typeof state.undefined === 'object' || state.undefined !== oldState.undefined ) ) {
		state.someProperty = newState.someProperty = template.computed.someProperty( state.val1, state.undefined );
	}

Thanks
Joe

Rich-Harris added a commit that referenced this issue Feb 1, 2017
handle default parameters in computed values
@Rich-Harris
Copy link
Member

Fixed in 1.6.8. Thanks!

@coulson84
Copy link
Author

speedy!

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 a pull request may close this issue.

2 participants