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

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

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

Comments

Projects
None yet
5 participants
@Krinkle
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).

@arthurvr

This comment has been minimized.

Show comment
Hide comment
Member

arthurvr commented Jan 7, 2015

@timmywil

This comment has been minimized.

Show comment
Hide comment
@timmywil

timmywil Jan 7, 2015

Member

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

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

Work around $.parseHTML( '' ) returning null
$.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

This comment has been minimized.

Show comment
Hide comment
@arthurvr

arthurvr Jan 7, 2015

Member

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

Member

arthurvr commented Jan 7, 2015

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

jdforrester added a commit to wikimedia/mediawiki-extensions-VisualEditor that referenced this issue Jan 8, 2015

Work around $.parseHTML( '' ) returning null
$.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)

@dmethvin dmethvin added Core Bug labels Jan 15, 2015

@timmywil timmywil closed this in 4116914 Jan 19, 2015

timmywil added a commit that referenced this issue Jan 19, 2015

@markelog markelog added Behavior Change and removed Bug labels Nov 10, 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.