infinite-viewer icon indicating copy to clipboard operation
infinite-viewer copied to clipboard

new InfiniteViewer will empty the iframe

Open zlyyyy opened this issue 1 year ago • 7 comments

There is an iframe in the viewport, and the content of the iframe will be cleared after the new InfiniteViewer

zlyyyy avatar Jun 16 '23 14:06 zlyyyy

Here is my minimal rendition https://stackblitz.com/edit/stackblitz-starters-rb32s7?file=src%2FApp.tsx

zlyyyy avatar Jun 16 '23 14:06 zlyyyy

image emty dom

zlyyyy avatar Jun 16 '23 14:06 zlyyyy

@daybrush Trying to downgrade the version can't solve it, it seems to be a persistent problem

zlyyyy avatar Jun 16 '23 14:06 zlyyyy

image It is normal to write before iframe write, and init will reproduce after write

zlyyyy avatar Jun 16 '23 15:06 zlyyyy

After looking at the source code, these two lines of code lead to

        if (!wrapperElement) {
            wrapperElement = doc.createElement("div");
            wrapperElement.insertBefore(this._viewportElement, null);
            containerElement.insertBefore(wrapperElement, null);
        }

zlyyyy avatar Jun 16 '23 16:06 zlyyyy

@zlyyyy

If there is an iframe inside the viewport, refresh may occur during the process of appendChild and insertBefore. As in your comment, it's probably best to set the wrapperElement as an ad-hoc.

The framework also creates a wrapper and sets it through props.

daybrush avatar Jun 19 '23 16:06 daybrush

@daybrush Yes, I temporarily solved it by setting wrapperElement

zlyyyy avatar Jun 19 '23 16:06 zlyyyy