Skip to content

Commit 7d46636

Browse files
committed
Remove unused setProps from Svelte JsComponent
Users should rely on Svelte $bindable to update viewmodel properties
1 parent c0b34bc commit 7d46636

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

src/Framework/JsComponent.Svelte/src/lib/dotvvm-svelte.svelte.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,29 @@ function getKnockoutContext(element: HTMLElement): KnockoutBindingContext {
3333
/**
3434
* Converts Svelte 5 component to DotVVM component usable through `<js:MyComponent />` syntax (or the JsComponent class).
3535
* See [the complete guide](https://www.dotvvm.com/docs/4.0/pages/concepts/client-side-development/integrate-third-party-controls/svelte).
36-
*
36+
*
3737
* The component will receive all properties, commands and templates as Svelte props.
3838
* * Properties are plain JS objects and values, notably they don't contain any knockout observables
3939
* * Commands are functions returning a promise, optionally expecting arguments if they were specified in the dothtml markup
40-
* * Templates are only string IDs which can be passed to the `KnockoutTemplateSvelteComponent`
41-
*
40+
* * Templates are only string IDs which can be passed to the `KnockoutTemplateSvelteComponent`
41+
*
4242
* Additional property `setProps` is passed to the component, which can be used to update the component's properties (if the bound expression is updatable, otherwise it will throw an error).
4343
* * Usage: `props.setProps({ myProperty: props.myProperty + 1 })`
4444
*/
4545
export const registerSvelteControl = <T extends Record<string, any>>(
46-
SvelteControl: Component<T>,
46+
SvelteControl: Component<T>,
4747
defaultProps: Partial<T> = {}
4848
) => ({
4949
create: (elm: HTMLElement, props: any, commands: any, templates: any, setProps: (props: any) => void) => {
50-
// const setProps = (updatedProps: any) => {
51-
// currentProps = { ...currentProps, ...updatedProps }
52-
// setPropsRaw(updatedProps)
53-
// TODO
54-
// }
55-
5650
const initialProps = { ...defaultProps, ...commands, ...templates }
5751
let currentProps = { ...initialProps, ...props }
58-
52+
5953
const events: Record<string, any> = {}
6054
for (const cmd of Object.keys(commands)) {
6155
if (cmd.startsWith('on')) {
6256
// Convert onHover -> hover, on:hover -> hover
6357
const eventName = cmd[2] === ':' ? cmd.substring(3) : cmd[2].toLowerCase() + cmd.substring(3)
64-
58+
6559
// Listen to custom events from the component
6660
events[eventName] = (event: any) => {
6761
commands[cmd](event.detail)

0 commit comments

Comments
 (0)