Bug Tracker

Opened 12 years ago

Closed 11 years ago

#11226 closed bug (fixed)

.after and .before returns incorrect data for $('not_existing_element')

Reported by: yurk Owned by:
Priority: high Milestone: 1.9
Component: manipulation Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:



expected: return a jquery object for '<existing_element>'
actually: works as expected


expected: return an empty jquery object

actually: returns a jquery object for newly created '<h2/>'

Change History (6)

comment:1 Changed 12 years ago by yurk

jquery 1.7.1 also affected

comment:2 Changed 12 years ago by dmethvin

Component: unfiledmanipulation
Priority: undecidedhigh
Status: newopen

Wow, interesting case. And by interesting I mean pain in the ass.

At some point a while back we decided to support things like $("<p>hello</p>").after("<p>world</p>") to get you two paragraphs in the collection. Prior to that I don't recall what it did, probably broke.

I agree though that it seems wrong to have .after() or .before() add stuff to an empty collection. I wonder whose code we'll break by fixing this.


comment:3 Changed 12 years ago by yurk

Yes, adding stuff to a primary collection by .after() and .before() is not so useful for chain-style coding.

An another bug posted into http://bugs.jquery.com/ticket/11230 could be related to this.

comment:4 Changed 11 years ago by saiwong

This has been fixed in #12664.

Recommend ticket be closed.

comment:5 Changed 11 years ago by mikesherov

Thanks for catching these, Sai. We'll close after discussing in the meeting today!

comment:6 Changed 11 years ago by mikesherov

Milestone: None1.9
Resolution: fixed
Status: openclosed

fixed in #12664.

Note: See TracTickets for help on using tickets.