Currently, the "attachments"-table always uses "attachments" as ID for the generated table.
if (count($rows)) {
return theme('table', $header, $rows, array('id' => 'attachments'));
}
There are a lot of situations in which more than one "attachments"-table is displayed on a page. Issue comments are an example: a random example shows 6 different places where "<table id='attachments' ..." is used.
The W3C validation flags this as invalid markup:
# Error Line 109, Column 11: ID "attachments" already defined.
<table id="attachments">
An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).
Attached is a patch against HEAD which replaces the use of "ID" by the use of "class".
Comments
Comment #2
mr.baileysre-rolled
Comment #3
mr.baileysAdditional reasoning as to why the current usage of the ID attribute in theme_upload_attachments is a bug: Drupal Markup Style Guide
Comment #4
mr.baileysI think this qualifies as a quick fix.
Comment #5
puradata commentedPatch needs work. It adds two classes "attachment" and "sticky-enable". I think the intention is to have one class "attachment"
Comment #6
mr.baileysThanks for reviewing this patch.
The "sticky-enable" & "sticky-table" classes are added automatically when a table has a header. This patch doesn't address nor change this behavior. Below are two excerpts, the first one of an attachments-table rendered without this patch applied, the second one with this patch applied.
before
after
No, the intention is to add an extra class (attachments), while removing the id (since we cannot guarantee that it will be unique on a rendered page)
Comment #7
puradata commentedmy bad. The patch works correctly.
Comment #8
mr.baileysTagging as an XHTML validation problem.
Comment #9
catchLooks great. Could probably do with a small note in the theme upgrade documentation after commit.
Comment #10
dries commentedCommitted to CVS HEAD. Thanks!
Comment #11
andypostPlease, backport this to 6 branch
Comment #12
mr.baileysNot sure if it's wise to backport this to D6: existing D6 themes might rely on the ID, and they might break if this gets backported...
Comment #13
andypostExisting D6 themes can be patched to track this change
But new D6 themes should have valid markup
Comment #14
catchCan you do a grep of the themes repository for #attachments ?
Comment #15
andypostAt this moment I can't
Comment #16
andypostNow results:
So it not hard to notify them with issues
Comment #17
andypostfix tags
so why d6 can allow invalid markup?
Comment #18
mr.baileysMarked #529556: Attachments not assigning a unique ID as duplicate of this issue.
edit: fixed link.
Comment #19
Anonymous (not verified) commentedI'm going to guess this is a won't fix for D6, since D6 commits focus on security fixes at this point.
Comment #20
Anonymous (not verified) commentedChanging issue status to reflect that it was fixed in 7.x.