Skip to content

jquery-migrate handling stray text different than jQuery #27

Closed
@dana-ross

Description

@dana-ross

Researching a WordPress issue: http://core.trac.wordpress.org/ticket/23055

Server-side code for an AJAX call was adding a stray "0" character outside the root element of an HTML fragment. For example:

<li>example</li>0

(we've patched the code that was doing this)

When this HTML is passed to jQuery.fn.init, jQuery 1.8.3 and 1.9.1 both ignore the trailing 0 as it isn't matched by rquickExpr.

In jquery-migrate's version of jQuery.fn.init, the HTML is passed through jQuery.parseHTML before calling the original jQuery.fn.init(). The parseHTML method is returning a two-element jQuery collection with the LI element and the 0.

Since jQuery.fn.init is passed a collection, there's no need to compare against rquickExpr and the 0 never ends up getting stripped out.

Sure, it's bad HTML that never should have been generated in the first place, but I'm thinking jquery-migrate shouldn't be changing the behavior here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions