1j01/98

`TypeError: container_node is null` when toggling "View as Web Page" in Firefox

1j01 opened this issue · 0 comments

1j01 commented

In the Explorer app, while viewing a folder, toggling View > as Web Page is causing an error in Firefox:

Uncaught TypeError: container_node is null
    handle_focus_in_out http://127.0.0.1:1998/lib/os-gui/$Window.js:492
    empty jQuery
    render_folder_template http://127.0.0.1:1998/programs/explorer/explorer.js:865
    onConfigure http://127.0.0.1:1998/programs/explorer/explorer.js:239
    configure http://127.0.0.1:1998/src/FolderView.js:170
    toggle http://127.0.0.1:1998/programs/explorer/menus.js:11
    item_action http://127.0.0.1:1998/lib/os-gui/MenuBar.js:883
    add_menu_item http://127.0.0.1:1998/lib/os-gui/MenuBar.js:915
    add_menu_item http://127.0.0.1:1998/lib/os-gui/MenuBar.js:909
    add_menu_item http://127.0.0.1:1998/lib/os-gui/MenuBar.js:896
    MenuPopup http://127.0.0.1:1998/lib/os-gui/MenuBar.js:948
    make_menu_button http://127.0.0.1:1998/lib/os-gui/MenuBar.js:964
    MenuBar http://127.0.0.1:1998/lib/os-gui/MenuBar.js:1084
    <anonymous> http://127.0.0.1:1998/programs/explorer/menus.js:588

logical_container_el.contentDocument is null here as the iframe is unloaded when toggling the folder template ("Web Page"):

98/lib/os-gui/$Window.js

Lines 485 to 492 in 7357f92

function make_focus_in_out_handler(logical_container_el, is_root) {
// In case of iframes, logical_container_el is the iframe, and container_node is the iframe's contentDocument.
// container_node is not a parameter here because it can change over time, may be an empty document before the iframe is loaded.
return function handle_focus_in_out(event) {
// @ts-ignore (not using instanceof for type narrowing, since this needs to work with across iframe contexts)
const container_node = logical_container_el.tagName == "IFRAME" ? logical_container_el.contentDocument : logical_container_el;
const document = container_node.ownerDocument ?? container_node;