d3-celestial icon indicating copy to clipboard operation
d3-celestial copied to clipboard

Failed to execute 'querySelectorAll' on 'Element': '#celestial*' is not a valid selector.

Open fmilioni opened this issue 5 years ago • 2 comments

If you call the display function twice, the following error occurs: Failed to execute 'querySelectorAll' on 'Element': '#celestial*' is not a valid selector.

The problem started after this commit: https://github.com/ofrohn/d3-celestial/commit/9bae16e3c0718e3aa0778f623df9fdb4b8d8c25e. It's looks like the selector is invalid at this line:

if (container) container.selectAll(parentElement + "*").remove();

(if you do a basic test with document.querySelectAll('#celestial*'), the same problem will occur.)


I did a temporary fix in my code using this snippet:

Captura de Tela 2020-09-14 às 19 25 54

fmilioni avatar Sep 14 '20 22:09 fmilioni

Yeah, there was a space missing. Should be fixed now

ofrohn avatar Sep 15 '20 19:09 ofrohn

@ofrohn Looks like it's not working properly yet. It does fix the selector but not everything is being deleted from the DOM. I'm using version 0.7.34.

Captura de Tela 2020-09-17 às 10 05 32

My temp workaround

useLayoutEffect(() => {
    //  FIXME  remove celestial-form
    const form = document.getElementById('celestial-form');
    if (form) form.remove();

    celestial.display(cfg);
  }, [options]);

I'll release d3-celestial as a react component soon, i'm very excited =)

fmilioni avatar Sep 17 '20 13:09 fmilioni