Bug Tracker

Opened 6 years ago

Closed 6 years ago

#13702 closed bug (invalid)

Inappropriate insertion of a tbody

Reported by: Arantor Owned by: Arantor
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

Ref https://github.com/jquery/jquery/blob/master/src/manipulation.js#L293 onwards

If you attempt to add a tr to a table, jQuery will realise that you're adding a tr and attempt to check that you're adding it to a table with a tbody, and if not, it will wrap the tr in a tbody before adding it to the table.

Ordinarily this would be fine, but I have the situation where I have a table with multiple tbody tags, each of which with ids. The problem is that if I select my tbody directly, my tr is added with a nested tbody (creating tbody#myid tbody tr as a hierarchy)

Line 314 shows it looking for a table with tbody, which is fine if you're targeting the table directly but in my case I'm not targeting the table, I need to target the tbody specifically to add it to the right container.

Currently I'm adding it to the tbody, then performing $("tbody#myid tbody tr").unwrap(); afterwards to strip the extra layer of tbody that's unnecessary, but as you can probably imagine I'd prefer not to do that.

I should also add, the original version of the code was written a year or more ago and I seem to remember we were using 1.5.2 back then - but back then, the code indicated worked fine (i.e. I could select a tbody by id and then directly append tr to it without any problems) so I'm wondering if this is a regression.

Change History (5)

comment:1 Changed 6 years ago by gibson042

Owner: set to Arantor
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 6 years ago by Arantor

Status: pendingnew

It's weird. I can't seem to reproduce it with jsFiddle, yet I've found two separate instances in our application where it was working correctly with 1.5.2 and not with 1.9.x or 2.0.

I can't share the actual code at this time, unfortunately.

comment:3 Changed 6 years ago by Arantor

Also, http://stackoverflow.com/a/10904232 is what put me onto this behaviour in jQuery in the first place.

comment:4 Changed 6 years ago by m_gol

Status: newpending

It's impossible for us to fix the bug without a test case, you either need to create one (I know this can be difficult but somebody always has to do it to nail the issue) so I'm changing the status back into pending. If you can't reproduce it, this issue will have to be closed.

Last edited 6 years ago by m_gol (previous) (diff)

comment:5 Changed 6 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.