zoid icon indicating copy to clipboard operation
zoid copied to clipboard

Bug: Zoid erroneously says container element removed from DOM when modifying HTML body

Open UsAndRufus opened this issue 3 years ago • 1 comments

Here's a bug I found.

  1. Import Zoid
  2. Modify document.body, eg document.body.innerHTML += 'test'
  3. Render a Zoid component into a container element (not the default of document.body)
  4. Component does not render, gives error Uncaught Error: Detected container element removed from DOM

So, modifying the document body makes Zoid fail to render, even though it is modified before the call to render and even though we are rendering into an element rather than the body.

Zoid part of the stack trace:

Uncaught Error: Detected container element removed from DOM
    at zoid.js:3699
    at zoid.js:1072
    at elementClosed (zoid.js:3663)
    at zoid.js:3668
    at zoid.js:3698
    at ZalgoPromise._proto.dispatch (zoid.js:245)
    at ZalgoPromise._proto.then (zoid.js:282)
    at renderContainer (zoid.js:3634)
    at zoid.js:4068
    at ZalgoPromise._proto.dispatch (zoid.js:245)

Tested in Chrome for Mac Version 92.0.4515.131 (Official Build) (x86_64).

Tested with Zoid 9.0.73 and 9.0.31.

UsAndRufus avatar Aug 18 '21 16:08 UsAndRufus

I had the same problem, and I put a setTimeout before making the DOM changes

ady642 avatar Oct 27 '22 11:10 ady642