=== modified file 'includes/theme.inc'
--- includes/theme.inc	2009-09-09 21:44:01 +0000
+++ includes/theme.inc	2009-09-10 17:06:28 +0000
@@ -2042,6 +2042,10 @@ function template_preprocess(&$variables
   // Initialize html class attribute for the current hook.
   $variables['classes_array'] = array($hook);
 
+  // Initialize attributes for the top-level template entity and its title.
+  $variables['attributes_array'] = array();
+  $variables['title_attributes_array'] = array();
+
   // Set default variables that depend on the database.
   $variables['is_admin']            = FALSE;
   $variables['is_front']            = FALSE;
@@ -2064,8 +2068,19 @@ function template_preprocess(&$variables
  * A default process function used to alter variables as late as possible.
  */
 function template_process(&$variables, $hook) {
+  // Prevent from having two class attributes in the same HTML tag by moving
+  // the eventual classes defined in attributes_array into classes_array.
+  if (isset($variables['attributes_array']['class']) && is_array($variables['attributes_array']['class'])) {
+    $variables['classes_array'] = array_merge($variables['attributes_array']['class'], $variables['classes_array']);
+    unset($variables['attributes_array']['class']);
+  }
+
   // Flatten out classes.
   $variables['classes'] = implode(' ', $variables['classes_array']);
+
+  // Flatten out attributes and title_attributes.
+  $variables['attributes'] = drupal_attributes($variables['attributes_array']);
+  $variables['title_attributes'] = drupal_attributes($variables['title_attributes_array']);
 }
 
 /**

Index: modules/block/block.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.tpl.php,v
retrieving revision 1.3
diff -u -p -r1.3 block.tpl.php
--- modules/block/block.tpl.php	12 Jun 2009 09:02:55 -0000	1.3
+++ modules/block/block.tpl.php	5 Sep 2009 15:33:56 -0000
@@ -35,9 +35,9 @@
  * @see template_process()
  */
 ?>
-<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>">
+<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
 <?php if ($block->subject): ?>
-  <h2><?php print $block->subject ?></h2>
+  <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
 <?php endif;?>
 
   <div class="content">
Index: modules/comment/comment-wrapper.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment-wrapper.tpl.php,v
retrieving revision 1.7
diff -u -p -r1.7 comment-wrapper.tpl.php
--- modules/comment/comment-wrapper.tpl.php	28 Jul 2009 10:09:25 -0000	1.7
+++ modules/comment/comment-wrapper.tpl.php	5 Sep 2009 15:33:57 -0000
@@ -30,7 +30,7 @@
  * @see theme_comment_wrapper()
  */
 ?>
-<div id="comments" class="<?php print $classes; ?>">
+<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
   <?php if ($node->type != 'forum'): ?>
     <h2 class="comments"><?php print t('Comments'); ?></h2>
   <?php endif; ?>
Index: modules/comment/comment.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.tpl.php,v
retrieving revision 1.11
diff -u -p -r1.11 comment.tpl.php
--- modules/comment/comment.tpl.php	29 Aug 2009 04:16:14 -0000	1.11
+++ modules/comment/comment.tpl.php	5 Sep 2009 15:33:57 -0000
@@ -44,14 +44,14 @@
  * @see theme_comment()
  */
 ?>
-<div class="<?php print $classes; ?> clearfix">
+<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
   <?php print $picture ?>
 
   <?php if ($new): ?>
     <span class="new"><?php print $new ?></span>
   <?php endif; ?>
 
-  <h3><?php print $title ?></h3>
+  <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
 
   <div class="submitted">
     <?php
Index: modules/field/field.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.module,v
retrieving revision 1.30
diff -u -p -r1.30 field.module
--- modules/field/field.module	28 Aug 2009 06:51:07 -0000	1.30
+++ modules/field/field.module	5 Sep 2009 15:33:58 -0000
@@ -670,8 +670,24 @@ function template_preprocess_field(&$var
     ),
   );
   $variables = array_merge($variables, $additions);
+
+  // Initialize attributes for each item.
+  foreach ($variables['items'] as $delta => $item) {
+    $variables['item_attributes_array'][$delta] = array();
+  }
 }
 
 /**
+ * Theme process function for field.tpl.php.
+ *
+ * @see field.tpl.php
+ */
+function template_process_field(&$variables) {
+  // Flatten out attributes for each item.
+  foreach ($variables['items'] as $delta => $item) {
+    $variables['item_attributes'][$delta] = drupal_attributes($variables['item_attributes_array'][$delta]);
+  }
+}
+/**
  * @} End of "defgroup field"
  */
Index: modules/field/theme/field.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/theme/field.tpl.php,v
retrieving revision 1.5
diff -u -p -r1.5 field.tpl.php
--- modules/field/theme/field.tpl.php	28 Aug 2009 06:51:07 -0000	1.5
+++ modules/field/theme/field.tpl.php	5 Sep 2009 15:33:58 -0000
@@ -39,13 +39,13 @@
  */
 ?>
 <?php if ($items) : ?>
-  <div class="field <?php print $classes; ?> clearfix">
+  <div class="field <?php print $classes; ?> clearfix"<?php print $attributes; ?>>
     <?php if (!$label_hidden) : ?>
-      <div class="field-label"><?php print $label ?>:&nbsp;</div>
+      <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
     <?php endif; ?>
     <div class="field-items">
       <?php foreach ($items as $delta => $item) : ?>
-        <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"><?php print render($item); ?></div>
+        <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
       <?php endforeach; ?>
     </div>
   </div>
Index: modules/node/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.tpl.php,v
retrieving revision 1.21
diff -u -p -r1.21 node.tpl.php
--- modules/node/node.tpl.php	29 Aug 2009 04:16:15 -0000	1.21
+++ modules/node/node.tpl.php	5 Sep 2009 15:33:59 -0000
@@ -70,12 +70,12 @@
  * @see template_process()
  */
 ?>
-<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix">
+<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
 
   <?php print $user_picture; ?>
 
   <?php if (!$page): ?>
-    <h2><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
+    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
   <?php endif; ?>
 
   <?php if ($display_submitted || !empty($content['links']['terms'])): ?>
Index: themes/garland/block.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/block.tpl.php,v
retrieving revision 1.8
diff -u -p -r1.8 block.tpl.php
--- themes/garland/block.tpl.php	5 Sep 2009 08:53:29 -0000	1.8
+++ themes/garland/block.tpl.php	5 Sep 2009 15:34:04 -0000
@@ -1,10 +1,10 @@
 <?php
 // $Id: block.tpl.php,v 1.8 2009/09/05 08:53:29 dries Exp $
 ?>
-<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix">
+<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
 
 <?php if (!empty($block->subject)): ?>
-  <h2 class="title"><?php print $block->subject ?></h2>
+  <h2 class="title"<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
 <?php endif;?>
 
   <div class="content"><?php print $content ?></div>
Index: themes/garland/comment.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/comment.tpl.php,v
retrieving revision 1.15
diff -u -p -r1.15 comment.tpl.php
--- themes/garland/comment.tpl.php	29 Aug 2009 04:16:15 -0000	1.15
+++ themes/garland/comment.tpl.php	5 Sep 2009 15:34:04 -0000
@@ -1,7 +1,7 @@
 <?php
 // $Id: comment.tpl.php,v 1.15 2009/08/29 04:16:15 webchick Exp $
 ?>
-<div class="<?php print $classes . ' ' . $zebra; ?>">
+<div class="<?php print $classes . ' ' . $zebra; ?>"<?php print $attributes; ?>>
 
   <div class="clearfix">
 
@@ -13,7 +13,7 @@
 
   <?php print $picture ?>
 
-    <h3><?php print $title ?></h3>
+    <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
 
     <div class="content">
       <?php hide($content['links']); print render($content); ?>
Index: themes/garland/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/node.tpl.php,v
retrieving revision 1.15
diff -u -p -r1.15 node.tpl.php
--- themes/garland/node.tpl.php	29 Aug 2009 04:16:15 -0000	1.15
+++ themes/garland/node.tpl.php	5 Sep 2009 15:34:04 -0000
@@ -1,12 +1,12 @@
 <?php
 // $Id: node.tpl.php,v 1.15 2009/08/29 04:16:15 webchick Exp $
 ?>
-<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>">
+<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
 
   <?php print $user_picture; ?>
 
   <?php if (!$page): ?>
-    <h2><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
+    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
   <?php endif; ?>
 
   <?php if ($display_submitted): ?>
