1j01 / 98

💿 Web-based Windows 98 desktop recreation █████▓█▓▓▒▓▒▒░▒░░░🗕︎🗗︎🗙︎
https://98.js.org
1.15k stars 183 forks source link

Can't click to select icon in folder browser in Firefox #92

Closed 1j01 closed 2 months ago

1j01 commented 2 months ago

In the Windows Explorer app, single-clicking isn't working to select a file or folder.

The error in Firefox is:

Uncaught TypeError: item_el_to_select is undefined
    select_item http://127.0.0.1:1998/src/FolderView.js:719
    setTimeout handler*select_item http://127.0.0.1:1998/src/FolderView.js:718
    FolderView http://127.0.0.1:1998/src/FolderView.js:464
    (jQuery x7...)
    FolderView http://127.0.0.1:1998/src/FolderView.js:461
    FolderView http://127.0.0.1:1998/src/FolderView.js:542
    go_to http://127.0.0.1:1998/programs/explorer/explorer.js:228
    async* http://127.0.0.1:1998/programs/explorer/explorer.js:1001
    setTimeout handler* http://127.0.0.1:1998/programs/explorer/explorer.js:999
    (jQuery x8...)
1j01 commented 2 months ago

So, instanceof is definitely inconsistent between Chrome and Firefox.

I created a simple test fiddle to demonstrate the difference.

Demonstration Code ```js // Create an iframe element var iframe = document.createElement('iframe'); // Add the iframe to the page iframe.style.width = '300px'; iframe.style.height = '150px'; document.body.appendChild(iframe); iframe.onload = function() { var outerDocument = document; var innerDocument = iframe.contentDocument || iframe.contentWindow.document; // Create an element within the context of the outer document var outsiderElement = outerDocument.createElement('div'); outsiderElement.textContent = 'Outsider Element'; // Create an element within the context of the inner document var insiderElement = innerDocument.createElement('span'); insiderElement.textContent = 'Insider Element'; // Append both elements to the iframe's document innerDocument.body.appendChild(outsiderElement); innerDocument.body.appendChild(insiderElement); // Log whether each element is an instance of Element console.log('outsiderElement instanceof Element:', outsiderElement instanceof Element); console.log('insiderElement instanceof Element:', insiderElement instanceof Element); console.log('outsiderElement:', outsiderElement); console.log('insiderElement:', insiderElement); }; iframe.src = 'about:blank'; ```

I concluded that:

Then I searched and found this relevant bug, which has been open for 6 years: Consider to not change prototype when adopting nodes