-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix several HTMLImageElement#complete bugs #2967
Conversation
07cccad
to
4f01e47
Compare
jsdom implements HTMLImageElement#complete poorly. I noticed this when I observed .complete giving false despite the onerror callback being called. To address this, perform the following changes: * Make .complete true if src is unset or is empty. * Make .complete true if an error occurs loading the image. * Make .complete false if .src is reset to an unloaded URL. This commit fixes most (but not all) test cases in html/semantics/embedded-content/the-img-element/img.complete.html. This commit does not address srcset or the image list.
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.
Looking great, just some nits; thanks!
@@ -5,7 +5,16 @@ const HTMLElementImpl = require("./HTMLElement-impl").implementation; | |||
const { Canvas } = require("../../utils"); | |||
const { parseURLToResultingURLRecord } = require("../helpers/document-base-url"); | |||
|
|||
const REQUEST_STATE_BROKEN = "broken"; | |||
const REQUEST_STATE_COMPLETELY_AVAILABLE = "completely available"; | |||
const REQUEST_STATE_UNAVAILABLE = "unavailable"; |
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.
Let's eliminate these and just use the strings directly.
@@ -0,0 +1,43 @@ | |||
<!DOCTYPE html> |
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.
Can you name this -dont-upstream.html
since it's a copy of an existing file and we need to remember not to upstream it?
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.
Hmm I see it's not a copy of an existing file... I'll give this some thought.
I'm trying to push fixes to this branch but I cannot do so. Can you ensure that "Allow edits from maintainers" is checked, per https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork ? |
In particular, now: * complete returns true if src="" is unset or empty. * complete returns true if an error occurs loading the image. * complete returns false if src="" is reset to a not-yet-loaded URL. Closes #2967 by superseding it. Co-authored-by: Matthew Glazar <strager.nds@gmail.com>
jsdom implements HTMLImageElement#complete poorly. I noticed this when I observed .complete giving false despite the onerror callback being called. To address this, perform the following changes:
This commit fixes most (but not all) test cases in html/semantics/embedded-content/the-img-element/img.complete.html. This commit does not address srcset or the image list.