toolness / p5.js-widget

A reusable widget for embedding editable p5 sketches in web pages.
https://toolness.github.io/p5.js-widget/
GNU Lesser General Public License v2.1
161 stars 44 forks source link

Some error types don't show error line in Firefox #73

Open freaktiful opened 4 years ago

freaktiful commented 4 years ago

When trying this widget in firefox, an error in particular (ReferenceError) does not show the error line. It does in chrome, though.

firefox error

When inspecting the problem, it seems that in Firefox, the filename returned is not only the page URL, but said URL and more text.

firefox error line

Thus, in preview-frame.bundle.js, when checking:

if (typeof (e.lineno) === 'number' &&
                (e.filename === '' || e.filename === window.location.href)) {
                line = e.lineno;
            }

It never satisfies the condition, and the variable line remains undefined.

I've changed (in my local code) the condition to:

(typeof (e.lineno) === 'number' &&
                (e.filename === '' || e.filename === window.location.href || e.filename.includes(window.location.href))) 

and it seems to work correctly.