Bug Tracker

Opened 5 years ago

Closed 4 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 5 years ago by yurk

jquery 1.7.1 also affected

comment:2 Changed 5 years ago by dmethvin

  • Component changed from unfiled to manipulation
  • Priority changed from undecided to high
  • Status changed from new to open
  • Version changed from 1.6.4 to 1.7.1

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 5 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 4 years ago by saiwong

This has been fixed in #12664.

Recommend ticket be closed.

comment:5 Changed 4 years ago by mikesherov

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

comment:6 Changed 4 years ago by mikesherov

  • Milestone changed from None to 1.9
  • Resolution set to fixed
  • Status changed from open to closed

fixed in #12664.

Note: See TracTickets for help on using tickets.