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

Prevent user from overwriting read-only handle #136

Merged
merged 5 commits into from
Dec 12, 2023

Conversation

TeyKey1
Copy link
Member

@TeyKey1 TeyKey1 commented Nov 22, 2023

This PR should partially fix #130

Currently, users are able to overwrite the konva handle from outside the component. As svelte-konva relies on the handle never being overwritten, this can cause various issues.

In Svelte there is no way of specifying a read-only binding as a normal user (although certain special elements such as HTML inputs do have read-only bindings). So the next best thing is to shadow the handle variable, which still enables the user to overwrite the handle prop of the component but not affecting the component itself in any way.

This leads to the implication that a user may unknowingly overwrite the handle prop (which is by all means wrong usage) but not receive any error due to svelte-konva not doing any runtime checks for such cases. This can lead to confusing behavior in case the user overwrites the handle with another Konva instance of the shape where the handle prop has now a different object instance compared to the konva instance of the component itself.

@TeyKey1 TeyKey1 merged commit f383130 into master Dec 12, 2023
4 checks passed
@TeyKey1 TeyKey1 deleted the feature/readonly-handle branch December 12, 2023 14:39
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.

TypeError: handle is undefined when rapidly updating
1 participant