Index: link.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/link/link.module,v
retrieving revision 1.24.4.9
diff -u -p -r1.24.4.9 link.module
--- link.module	5 Nov 2009 05:09:23 -0000	1.24.4.9
+++ link.module	9 Nov 2009 00:45:14 -0000
@@ -253,9 +253,9 @@ function _link_process(&$item, $delta = 
   // Trim whitespace from URL.
   $item['url'] = trim($item['url']);
 
-  // if no attributes are set use the default attributes.
+  // if no attributes are set then make sure $item['attributes'] is an empty array - this lets $field['attributes'] override it.
   if (empty($item['attributes'])) {
-    $item['attributes'] = _link_default_attributes();
+    $item['attributes'] = array(); 
   }
 
   // Serialize the attributes array.
@@ -564,6 +564,7 @@ function link_field_formatter_info() {
  * Theme function for 'default' text field formatter.
  */
 function theme_link_formatter_default($element) {
+  //drupal_set_message('<pre>'. print_r($element['#item'], TRUE) .'</pre>');
   // Display a normal link if both title and URL are available.
   if (!empty($element['#item']['display_title']) && !empty($element['#item']['url'])) {
     return l($element['#item']['display_title'], $element['#item']['url'], $element['#item']);
Index: tests/link.attribute.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/link/tests/Attic/link.attribute.test,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 link.attribute.test
--- tests/link.attribute.test	8 Nov 2009 23:04:57 -0000	1.1.2.3
+++ tests/link.attribute.test	9 Nov 2009 00:45:14 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: link.attribute.test,v 1.1.2.3 2009/11/08 23:04:57 jcfiala Exp $
+// $Id$
 
 /**
  * @file
@@ -102,4 +102,44 @@ class LinkAttributeCrudTest extends Cont
     $this->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com'));
   }
   
+  /**
+   * This test sees that we can create a link field with a defined class, and make sure
+   * that class displays properly when the link is displayed.
+   */
+  function testLinkWithClassOnField() {
+    $this->acquireContentTypes(1);
+    $field_settings = array(
+      'type' => 'link',
+      'widget_type' => 'link',
+      'type_name' => $this->content_types[0]->name,
+      'attributes' => array(
+        'class' => 'test-class',
+        'target' => 'default',
+        'rel' => FALSE,
+      ),
+    );
+    
+    $field = $this->createField($field_settings, 0);
+    //$this->pass('<pre>'. print_r($field, TRUE) .'</pre>');
+    $field_db_info = content_database_info($field);
+
+    $this->acquireNodes(2);
+    
+    $node = node_load($this->nodes[0]->nid);
+    $node->promote = 1; // We want this to show on front page for the teaser test.
+    $node->{$field['field_name']}[0] = $this->createLink('http://www.example.com', 'Test Link');
+    node_save($node);
+    
+    // Does this display on the node page?
+    $this->drupalGet('node/'. $this->nodes[0]->nid);
+    //$this->outputScreenContents('Link field with class', 'link_');
+    $this->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com', array('attributes' => array('class' => 'test-class'))));
+    
+    // Does this display on the front page?
+    $this->drupalGet('<front>');
+    // reset the zebra!
+    $this->zebra = 0;
+    $this->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com', array('attributes' => array('class' => 'test-class'))));
+  }
+  
 }
\ No newline at end of file
