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

multiple issues with managed insertBefore and replaceChild for cells #207

Open
thedavidmeister opened this issue Dec 23, 2017 · 1 comment
Milestone

Comments

@thedavidmeister
Copy link
Contributor

thedavidmeister commented Dec 23, 2017

I'm really struggling to get insertBefore to work properly with cells (cells are the only reason to introduce the prototype overrides AFAICS).

Here's a few confusing examples:

Two cells provided for x and y.

 (let [parent (h/div)
       x (j/cell "foo")
       y (j/cell "bar")]
  (is (= y (.appendChild parent y)))
  (is (= x (.insertBefore parent x y))) ; <-- seems to do nothing

  (is (= "foobar" (.-textContent parent))))) ; <-- actually "bar"

Mixing cells with divs.

 (let [parent (h/div)
       x (j/cell "foo")
       y (h/div "bar")]
  (is (= y (.appendChild parent y)))
  (is (= x (.insertBefore parent x y))) ; <-- throws #object[Object Error: NotFoundError: DOM Exception 8]

  (is (= "foobar" (.-textContent parent))))) ; <-- actually "bar"
 (let [parent (h/div)
       x (h/div "foo")
       y (j/cell "bar")]
  (is (= y (.appendChild parent y)))
  (is (= x (.insertBefore parent x y))) ; <-- no error this time, fails silently

  (is (= "foobar" (.-textContent parent))))) ; <-- actually "bar"

i also couldn't see anywhere in hoplon that the managed insert logic is actually used.

are we overriding the prototype for no reason here?
how is this supposed to work?

first noticed as part of testing at #205

@thedavidmeister thedavidmeister changed the title multiple issues with managed insertBefore multiple issues with managed insertBefore and replaceChild for cells Dec 23, 2017
@thedavidmeister
Copy link
Contributor Author

thedavidmeister commented Dec 23, 2017

finding identical looking issues for replaceChild called for child cells

 (let [parent (h/div)
       x (j/cell "foo")
       y (j/cell "bar")]
  (is (= y (.appendChild parent y)))
  (is (= y (.replaceChild parent x y)))

  (is (= "foo" (.-textContent parent)))) ; <-- "bar" => failing silently

 (let [parent (h/div)
       x (j/cell "foo")
       y (h/div "bar")]
  (is (= y (.appendChild parent y)))
  (is (= y (.replaceChild parent x y))) ; <-- throws #object[Object Error: NotFoundError: DOM Exception 8]

  (is (= "foo" (.-textContent parent)))) ; <-- "bar"

 (let [parent (h/div)
       x (h/div "foo")
       y (j/cell "bar")]
  (is (= y (.appendChild parent y)))
  (is (= y (.replaceChild parent x y)))

  (is (= "foo" (.-textContent parent))))) ; <-- "bar" => failing silently

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