Skip to content

Commit

Permalink
Simplify component wrapper method
Browse files Browse the repository at this point in the history
  • Loading branch information
7-zete-7 committed Sep 28, 2024
1 parent edf49f4 commit b957699
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
24 changes: 10 additions & 14 deletions src/Vue/assets/dist/render_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,16 @@ class default_1 extends Controller {
this.dispatch(name, { detail: payload, prefix: 'vue' });
}
wrapComponent(component) {
return defineComponent({
setup: () => {
const props = this.props;
return () => h(component, {
...props,
...Object.fromEntries(Object.keys(props).map((propName) => [
`onUpdate:${propName}`,
(value) => {
props[propName] = value;
},
])),
});
},
});
const { props } = this;
return defineComponent(() => () => h(component, {
...props,
...Object.fromEntries(Object.keys(props).map((propName) => [
`onUpdate:${propName}`,
(value) => {
props[propName] = value;
},
])),
}));
}
}
default_1.values = {
Expand Down
31 changes: 13 additions & 18 deletions src/Vue/assets/src/render_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,18 @@ export default class extends Controller<Element & { __vue_app__?: App<Element> }
}

private wrapComponent(component: Component): Component {
return defineComponent({
setup: () => {
const props = this.props;

return () =>
h(component, {
...props,
...Object.fromEntries(
Object.keys(props).map((propName) => [
`onUpdate:${propName}`,
(value: unknown) => {
props[propName] = value;
},
])
),
});
},
});
const { props } = this;

return defineComponent(() => () => h(component, {
...props,
...Object.fromEntries(
Object.keys(props).map((propName) => [
`onUpdate:${propName}`,
(value: unknown) => {
props[propName] = value;
},
])
),
}));
}
}

0 comments on commit b957699

Please sign in to comment.