Skip to content

Commit

Permalink
Fix bug in class bindability detection, #534
Browse files Browse the repository at this point in the history
  • Loading branch information
cocopon committed Apr 8, 2023
1 parent 03bbd12 commit d0934e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/core/src/common/binding/target-test.ts
Expand Up @@ -29,4 +29,22 @@ describe(BindingTarget.name, () => {
target.write('wrote');
assert.strictEqual(obj.foo, 'wrote');
});

it('should bind static class field', () => {
class Test {
static foo = 1;
}

assert.doesNotThrow(() => {
new BindingTarget(Test, 'foo');
});
});

it('should determine class is bindable', () => {
class Test {
static foo = 1;
}

assert.strictEqual(BindingTarget.isBindable(Test), true);
});
});
2 changes: 1 addition & 1 deletion packages/core/src/common/binding/target.ts
Expand Up @@ -20,7 +20,7 @@ export class BindingTarget {
if (obj === null) {
return false;
}
if (typeof obj !== 'object') {
if (typeof obj !== 'object' && typeof obj !== 'function') {
return false;
}
return true;
Expand Down

0 comments on commit d0934e8

Please sign in to comment.