Skip to content

Exception thrown when root element is removed from DOM before / during appRender #194

@md-jafuss

Description

@md-jafuss

Our client hosts the F2 Container for the apps we have created for one of our projects and they have a structure setup so that they can remove elements off the DOM and add them back to the DOM when the tab for that content becomes the active view.

This page is a single page application so there isn't any full page refresh unless the user does this them self.

The issue they are running into is that an exception is thrown stating that their root element for the apps they pre-render are not in the DOM. The specific error is thrown in the following line of code (line 421) showing up in sdk\src\container.js (they are using the f2.min.js):

if (!elementInDocument(root)) {
throw ('App root for ' + appId + ' was not appended to the DOM. Check your AppHandler callbacks to ensure you have rendered the app root to the DOM.');
}

I did a quick test by removing this if statement, saved, then at the end of my appRender I stored the root element in a JavaScript object and removed the element from the DOM, and then it proceeded through the rest of the F2 code.
After the page was done loading I added the root element I saved in a JavaScript object back into the container it would have originally rendered and then tested that all the JavaScript and CSS was working / showing correctly.

It seemed to work as expected from what I could see so I was just wondering what the purpose of this if(!elementInDocument(root)) check is for and whether it is necessary for something to work properly in the F2 codebase?

Based on my small test I didn't see any issues but I could be missing something that is used in a more complicated scenario.
Please let me know if you need additional details to investigate or reply to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions