-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Core: Report browser errors in parseXML #4816
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
Conversation
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 wonder if we should preserve the old Invalid XML:
prefix for compat reasons and just check for that in the unit test? We don't control the browser's reporting of XML errors so we can't ensure it will show any specific error message. What do you think? In either case it is an improvement!
I'm not sure either way. Judging by the messages I cited in the PR description, the Chrome error kind of misses the context so the |
I updated the PR with proposed changes; unfortunately, now it's at +25 bytes. |
@dmethvin does the current version look good to you? |
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.
LGTM!
Legacy Edge, similarly to IE, doesn't report XML parsing errors but just tries to render the invalid document. Skip the error reporting test there, Edge Legacy will return a generic "Invalid XML" error, just like IE. Ref jquerygh-4816
Summary
Fixes gh-4784
In IE 11 we'd just throw an empty error now, in others - the reported error. We wouldn't include input data in the thrown error anymore.
+10 bytes, although I cheated a bit - I also removed an assignment of
xml
toundefined
incatch
as any error would happen before the assignment so the variable would already hold theundefined
value. Without this optimization, it'd be +13 bytes.That +10 can be changed to -3 if we just call:
but that has two issues. Here's the returned element
parsererror
(after pretty-printing) in Blink & WebKit:and here's the one in Gecko:
If we just print
textContent
, in Chrome the text will miss spaces in some places:That may not be enough a reason to add bytes but here's what ends up in Firefox:
Firefox prints ASCII art which is misaligned now. With the code from this PR, here's what gets printed:
On the other hand, it actually uses tabs to pad
</tr>
and the alignment depends on tab being rendered as 8 characters... So maybe we can give up on that.EDIT: Actually, this will mostly be printed in the DevTools of the respective browser, here: Firefox. So it should show up correctly in the console.
Let's make a decision at the next meeting.
Checklist
If needed, a docs issue/PR was created at https://github.com/jquery/api.jquery.com