-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gluon-status-page: migrate JS to es2015
-standard
#2959
Conversation
Fix warning by Chrome: Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
dcbf9b1
to
6d7d6b1
Compare
try { | ||
location = JSON.parse(document.body.getAttribute('data-node-location')); | ||
} catch (e) { | ||
console.error(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is nothing wrong with a node not providing a location, this should not be logged.
We are slightly abusing the try/catch here though, something like the following would be nicer (untested):
const location_attr = document.body.getAttribute('data-node-location');
let location;
if (location_attr)
location = JSON.parse(location_attr);
try { | ||
lastImage = ctx.getImageData(0, 0, w, h); | ||
} catch (e) {} | ||
} catch (e) { | ||
console.error(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this should be logged. Unfortunately, I don't remember why I added the try/catch here...
MDN describes two possible exceptions: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData#exceptions
I don't think we can hit the SecurityError, so maybe this was just an ugly way to catch w
or h
being zero?
@Rotzbua Do you still have plans for addressing the suggestions? |
closing due to lack of reaction |
Change
es2015
-standardCanvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
Reference
Mentioned in #2953