Skip to content

Commit 2118260

Browse files
committed
[fix] Property Descriptor bug of watch decorator at runtime
1 parent c7f06b0 commit 2118260

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
tags:
55
- v*
66
jobs:
7-
Build-and-Deploy:
7+
Build-and-Publish:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout

MobX/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobx-web-cell",
3-
"version": "0.4.0-rc.3",
3+
"version": "0.4.0-rc.4",
44
"license": "LGPL-3.0",
55
"author": "[email protected]",
66
"description": "MobX adaptor for WebCell v2",
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"mobx": ">4.0.0 <6.0.0",
27-
"web-cell": "^2.4.0-rc.4"
27+
"web-cell": "^2.4.0-rc.5"
2828
},
2929
"devDependencies": {
3030
"@parcel/packager-ts": "^2.2.1",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web-cell",
3-
"version": "2.4.0-rc.4",
3+
"version": "2.4.0-rc.5",
44
"description": "Web Components engine based on JSX & TypeScript",
55
"keywords": [
66
"web",

source/decorator.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@ export function watch(
3434
meta?: PropertyDescriptor
3535
) {
3636
const accessor = !!(meta?.get || meta?.set);
37-
meta = meta || Object.getOwnPropertyDescriptor(prototype, key) || {};
3837

39-
meta.set =
40-
meta.set ||
41-
function (this: WebCellComponent, value) {
42-
this.setProps({ [key]: value });
43-
};
44-
meta.get =
45-
meta.get ||
46-
function () {
47-
return this.props[key];
48-
};
38+
if (!accessor) meta = {};
39+
40+
meta.set ||= function (this: WebCellComponent, value) {
41+
this.setProps({ [key]: value });
42+
};
43+
meta.get ||= function () {
44+
return this.props[key];
45+
};
4946
(meta.configurable = true), (meta.enumerable = true);
5047

5148
if (!accessor) Object.defineProperty(prototype, key, meta);

0 commit comments

Comments
 (0)