Skip to main content

Bug Tracker

Side navigation

#13702 closed bug (invalid)

Opened April 01, 2013 04:33AM UTC

Closed April 18, 2013 08:35AM UTC

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.

Attachments (0)
Change History (5)

Changed April 01, 2013 01:52PM UTC by gibson042 comment:1

owner: → 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.

Changed April 04, 2013 04:08AM UTC by Arantor comment:2

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.

Changed April 04, 2013 04:13AM UTC by Arantor comment:3

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

Changed April 04, 2013 04:37AM UTC by m_gol comment:4

_comment0: 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 bat 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.1365549863527337
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.

Changed April 18, 2013 08:35AM UTC by trac-o-bot comment:5

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!