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

Error for object nested with DOM elements #22

Open
robinchew opened this issue Jan 25, 2019 · 1 comment
Open

Error for object nested with DOM elements #22

robinchew opened this issue Jan 25, 2019 · 1 comment

Comments

@robinchew
Copy link

Following code causes Illegal Constructor error:

import O from 'patchinko/immutable.mjs'

console.log(O({selected: {dom: document.body}}, {
  selected: O({
    dom: O(oldDom => document.body),
  }),
}))

console.log(O({selected: {dom: null}}, {
  selected: O({
    dom: O(oldDom => document.body),
  }),
}))

Run above code in flems

@barneycarroll
Copy link
Owner

There are two issues here:

  1. Can and should immutable be expected to procedurally copy complex objects?
  2. Should immutable be trying to copy objects at all in the case where they're being handed to a scope?

1 is tough. Currently we have thing => new thing.constructor as the copy mechanism. I don't think it's in Patchinko's remit to special case DOM objects, where there's no unopinionated way to copy a node (should cloneNode be passed true?).

2 is a design mistake in Patchinko, I think. That merits its own issue - #23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants