Fix a bug with FRPtools when a container property is set to a falsey value
This commit is contained in:
parent
b6536700af
commit
9597b52941
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frptools",
|
||||
"version": "3.2.1",
|
||||
"version": "3.2.2",
|
||||
"description": "Observable Property and Computed data streams",
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
|
||||
@ -2,6 +2,17 @@ import { container, computed } from '../src/index.js';
|
||||
import { dirtyMock, hashSet } from '../src/testUtil.js';
|
||||
|
||||
describe('A container', () => {
|
||||
it('tracks properties', () => {
|
||||
let i = 0;
|
||||
const a = container({}, () => i++);
|
||||
|
||||
a.a = 1;
|
||||
expect(a.a).toBe(a._.a);
|
||||
|
||||
a.b = false;
|
||||
expect(a.b).toBe(a._.b);
|
||||
});
|
||||
|
||||
it('notifies dependents of updates', () => {
|
||||
let runCount = 0;
|
||||
let currentValue = new Set();
|
||||
|
||||
@ -48,7 +48,9 @@ export function container(store, hash) {
|
||||
target[name] = newVal;
|
||||
checkUpdate(target);
|
||||
|
||||
return newVal;
|
||||
// Returning a falsey value causes TypeError
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set#Invariants
|
||||
return newVal || true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user