Skip to content

Commit 85a034f

Browse files
committed
release: vue-class-setup@1.3.2
1 parent e37250e commit 85a034f

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.3.1
2+
3+
- fix: Vue3 SSR default error
4+
15
## 1.3.0
26

37
- Same as `1.2.9`

src/context.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ function use(vm: VueInstance, _This: any) {
4141
use = vm[SETUP_USE];
4242
} else {
4343
use = new Map();
44-
vm[SETUP_USE] = use;
44+
Object.defineProperty(vm, SETUP_USE, {
45+
get() {
46+
return use;
47+
},
48+
});
4549
}
4650
let app = use.get(_This)!;
4751
if (app) {
@@ -54,13 +58,20 @@ function use(vm: VueInstance, _This: any) {
5458
}
5559

5660
function proxyVue3Props(app: InstanceType<DefineConstructor>, vm: VueInstance) {
57-
const render = vm.$options?.render as Function | undefined;
61+
interface Item {
62+
ssrRender?: Function;
63+
render?: Function;
64+
}
65+
if (!vm.$) {
66+
return;
67+
}
68+
const item = vm.$ as Item;
69+
const render = item.ssrRender || item.render;
5870
if (app[SETUP_SETUP_DEFINE] && render) {
5971
const keys = Object.keys(app.$defaultProps);
6072
if (!keys.length) return;
6173
const proxyRender = (...args: any[]) => {
6274
const props = vm.$props;
63-
const defaultProps = app.$defaultProps;
6475
const arr: { key: string; pd: PropertyDescriptor }[] = [];
6576
const dpp = createDefineProperty(props);
6677
// Set default Props
@@ -83,10 +94,11 @@ function proxyVue3Props(app: InstanceType<DefineConstructor>, vm: VueInstance) {
8394
// Resume default props
8495
return res;
8596
};
86-
vm.$options.render = proxyRender;
8797

88-
if (vm.$) {
89-
(vm as any).$.render = proxyRender;
98+
if (item.ssrRender) {
99+
item.ssrRender = proxyRender;
100+
} else if (item.render) {
101+
item.render = proxyRender;
90102
}
91103
}
92104
}

0 commit comments

Comments
 (0)