Skip to content

$.parseHTML( "" ) should not return null #1997

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

Closed
Krinkle opened this issue Jan 7, 2015 · 3 comments
Closed

$.parseHTML( "" ) should not return null #1997

Krinkle opened this issue Jan 7, 2015 · 3 comments

Comments

@Krinkle
Copy link
Member

Krinkle commented Jan 7, 2015

This behaviour has been there since the version version (e2497c6) but I'd like to propose changing that.

The method is documented as taking a string (of HTML) and returning an Array. Having it return null for non-string input is fair, but for empty strings it should probably return an empty array (or maybe array with empty text node).

@timmywil
Copy link
Member

timmywil commented Jan 7, 2015

I like the empty array idea. It would be the same behavior as parsing natively with createHTMLDocument, and it shouldn't affect jQuery("").

wmfgerrit pushed a commit to wikimedia/mediawiki-extensions-VisualEditor that referenced this issue Jan 7, 2015
$.parseHTML() always returns an array, except in this one case,
so checking .length of the return value almost always works except
when it blows up in your face.

Filed upsteam as jquery/jquery#1997

Bug: T86056
Change-Id: If133a9df4d573b41b0ecb5bde47b3e6ada053921
@arthurvr
Copy link
Member

arthurvr commented Jan 7, 2015

Empty textnode would be inconsistent with browser' behaviour, so an empty array seems like a nice solution.

jdforrester pushed a commit to wikimedia/mediawiki-extensions-VisualEditor that referenced this issue Jan 8, 2015
$.parseHTML() always returns an array, except in this one case,
so checking .length of the return value almost always works except
when it blows up in your face.

Filed upsteam as jquery/jquery#1997

Bug: T86056
Change-Id: If133a9df4d573b41b0ecb5bde47b3e6ada053921
(cherry picked from commit f71054d)
timmywil pushed a commit that referenced this issue Jan 19, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

5 participants