Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reactive): support deletion of overriden properties in child context #50

Open
lowlighter opened this issue May 31, 2024 · 0 comments

Comments

@lowlighter
Copy link
Owner

When using Scope.with, if an overriden property is deleted from child context, it should not reappear from parent context.

This is currently not supported because it adds a priori a lot of complexity (we need to track which property from the root object were overriden and then deleted, in addition to remove this flag if it's set again, and everything without impacting parent context).

The following test case can be used to test this behaviour:

test("all")("Scope.with() contexts operates unidirectionaly when value is overidden from parent (delete operation)", () => {
  const a = new Context({ d: 0 })
  const b = a.with<testing>({ d: 1 })
  const listeners = { a: fn(), b: fn() }
  a.addEventListener("change", listeners.a)
  b.addEventListener("change", listeners.b)
  delete b.target.d
  expect(a.target.d).toBe(0)
  expect(b.target.d).toBeUndefined()
  expect(a.target).toHaveProperty("d")
  expect(b.target).not.toHaveProperty("d")
  expect(listeners.a).toHaveBeenCalledTimes(0)
  expect(listeners.b).toHaveBeenCalledTimes(1)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant