Open Bug 272267 Opened 20 years ago Updated 2 years ago

tfoot is copied after the thead (instead of after the tbody)

Categories

(Core :: DOM: Serializers, defect)

x86
All
defect

Tracking

()

REOPENED

People

(Reporter: justincwatt, Unassigned)

References

()

Details

Attachments

(1 file)

According to the HTML4 spec, "TFOOT must appear before TBODY within a TABLE
definition so that user agents can render the foot before receiving all of the
(potentially numerous) rows of data."
http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2.3

However when a table is copied out of webpage and pasted into an email or
spreadsheet, the THEAD, TFOOT, TBODY order is preserved.

Expected behavior would be for the table elements to be copied in the order they
are rendered by the browser, as opposed to the order they appear in the HTML source.
Component: Layout: Tables → DOM to Text Conversion
This is a subset of bug 272269, since we copy things in the order they're selected.

*** This bug has been marked as a duplicate of 272269 ***
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Reopening.  This could be fixed in the serializer without changing bug 272269
(serialize the thead, then tbodies, then the tfoot, when serializing a table).

In fact, the plaintext serializer should do just that, while the HTML serializer
should serialize in source order.

This matters most in the case when the entire table is selected, since then bug
272269 is quite simply not relevant.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
And it would be good to have a testcase attached to the bug.
Attached file testcase for bug
this html testcase demonstrates the bug and describes the expected vs. actual
behavior. it is the same file available at this url:
http://justinsomnia.org/mozilla/tfoot_copy_problem.html
What version is this bug for?

I've checked with both stable versions of Gecko v1.9.0.11 (Fx v3.0.11) and v1.9.1 (Fx v3.5) and it looks as it should.
> What version is this bug for?
I've just verified that this bug still persists in mozilla-central trunk, so it presumably affects 1.9.0 and 1.9.1, too.

> and it looks as it should.
Read comment 0 carefully -- this bug isn't about how the table *looks*, it's about what happens when the table is copied to the clipboard and then pasted elsewhere.

STEPS TO REPRODUCE:
 1. Load testcase
 2. Highlight a range that includes the whole table. (e.g. select from before the phrase "When the text" and up until after "IE6 exhibits the same behavior").
 3. Ctrl+C to copy
 4. In a text editor, Ctrl+V to paste

The purported expected behavior is that the "Total" line should be at the bottom of the table in the pasted text.  However, in mozilla-central trunk, it's not.

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2a1pre) Gecko/20090707 Minefield/3.6a1pre
OS: Windows XP → All
QA Contact: layout.tables → dom-to-text
In the latest update to the W3C validator service, there have been "changes the checker behavior to disallow tfoot before tbody (as required by the current HTML spec)".

https://github.com/validator/validator/blob/8fe5e1369860fcbc7ba798c0b40eb3b80ab3beec/WHATSNEW.md

This causes any DOM that is serialised from Firefox to then fail validation.

The Mozilla documentation on the tfoot element (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot) incorrectly states that tfoot should come before tbody, disagreeing with the HTML 5.2 Spec (http://w3c.github.io/html/single-page.html#the-tfoot-element - large page warning).
A more useful link that doesn't involve large pages and forked or out of date documents is https://html.spec.whatwg.org/multipage/tables.html#the-tfoot-element for what it's worth.

And yes, this was effectively a spec change from HTML 4 to HTML 5.  The documentation needs to be updated (and note that it's a wiki, if someone cares deeply and wants to just update it).

In terms of this bug, though, I'm not sure what the problem is at this point.  If I have valid (per HTML5 or later) source:

  <!DOCTYPE html>
  <table>
    <thead><tr><td>head</tr></td></thead>
    <tbody><tr><td>body</tr></td></tbody>
    <tfoot><tr><td>foot</tr></td></tfoot>
  </table> 

and I load that in Nightly, select-all (Ctrl-a or Cmd+a, depending on OS), copy, paste into an app that expects HTML, I get out head, body, foot in that order, just like in the original source.  So I'm not sure where the "any DOM that is serialised from Firefox to then fail validation" part is coming from...
Flags: needinfo?(irl)
Anyway, I updated https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot to reflect the current spec, with a note about the flat-out contradiction with HTML4.
With the documentation updated, I believe this bug to be fixed with the code and documentation both reflecting the current details of the specification.
Flags: needinfo?(irl)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: