commit c7932ddfb2a61769098cd6611fcb20bd761c1b41 Author: Joel Pittet Date: Sun Aug 17 02:49:08 2014 -0700 2031301 diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php index eef8e77..2a06eb6 100644 --- a/core/lib/Drupal/Core/Render/Element/Link.php +++ b/core/lib/Drupal/Core/Render/Element/Link.php @@ -56,13 +56,6 @@ public static function preRenderLink($element) { $element['#options']['attributes'] += $element['#attributes']; } - // Merge the provided attributes on top of the default attributes - // provided by the element definition. - if (isset($element['#default_attributes'])) { - $element['#options'] += array('attributes' => array()); - $element['#options']['attributes'] = NestedArray::mergeDeep($element['#default_attributes'], $element['#options']['attributes']); - } - // This #pre_render callback can be invoked from inside or outside of a Form // API context, and depending on that, a HTML ID may be already set in // different locations. #options should have precedence over Form API's #id. diff --git a/core/lib/Drupal/Core/Render/Element/MoreLink.php b/core/lib/Drupal/Core/Render/Element/MoreLink.php new file mode 100644 index 0000000..a8db83b --- /dev/null +++ b/core/lib/Drupal/Core/Render/Element/MoreLink.php @@ -0,0 +1,33 @@ + t('More'), + '#theme_wrappers' => array( + 'container' => array( + '#attributes' => array('class' => 'more-link'), + ), + ), + ) + $info; + } + +} diff --git a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php index 6a75e64..7391b48 100644 --- a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php +++ b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php @@ -114,7 +114,7 @@ function testMoreLink() { '#type' => 'more_link', '#href' => 'http://drupal.org', ), - 'expected' => '//a[@href="http://drupal.org" and @class="more-link" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="http://drupal.org" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag generation with different link text", @@ -123,19 +123,23 @@ function testMoreLink() { '#href' => 'http://drupal.org', '#title' => 'More Titles', ), - 'expected' => '//a[@href="http://drupal.org" and @class="more-link" and text()="More Titles"]', + 'expected' => '//div[@class="more-link"]/a[@href="http://drupal.org" and text()="More Titles"]', ), array( - 'name' => "#type 'more_link' anchor tag generation with extra classes", + 'name' => "#type 'more_link' anchor tag generation with attributes on wrapper", 'value' => array( '#type' => 'more_link', '#href' => 'http://drupal.org', - '#attributes' => array( - 'title' => 'description', - 'class' => array('drupal', 'test'), + '#theme_wrappers' => array( + 'container' => array( + '#attributes' => array( + 'title' => 'description', + 'class' => array('more-link', 'drupal', 'test'), + ), + ), ), ), - 'expected' => '//a[@href="http://drupal.org" and @title="description" and contains(@class, "more-link") and contains(@class, "drupal") and contains(@class, "test") and text()="More"]', + 'expected' => '//div[@title="description" and contains(@class, "more-link") and contains(@class, "drupal") and contains(@class, "test")]/a[@href="http://drupal.org" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag with a relative path", @@ -143,7 +147,7 @@ function testMoreLink() { '#type' => 'more_link', '#href' => 'a/link', ), - 'expected' => '//a[@href="' . url('a/link') . '" and @class="more-link" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . url('a/link') . '" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag with a route", @@ -152,7 +156,7 @@ function testMoreLink() { '#route_name' => 'router_test.1', '#route_parameters' => array(), ), - 'expected' => '//a[@href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" and @class="more-link" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag with an absolute path", @@ -161,7 +165,7 @@ function testMoreLink() { '#href' => 'admin/content', '#options' => array('absolute' => TRUE), ), - 'expected' => '//a[@href="' . url('admin/content', array('absolute' => TRUE)) . '" and @class="more-link" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . url('admin/content', array('absolute' => TRUE)) . '" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag to the front page", @@ -169,12 +173,12 @@ function testMoreLink() { '#type' => 'more_link', '#href' => '', ), - 'expected' => '//a[@href="' . url('') . '" and @class="more-link" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . url('') . '" and text()="More"]', ), ); foreach($elements as $element) { - $xml = new \SimpleXMLElement(drupal_render($element['value'])); + $xml = new \SimpleXMLElement(render($element['value'])); $result = $xml->xpath($element['expected']); $this->assertTrue($result, '"' . $element['name'] . '" input rendered correctly by drupal_render().'); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index ba7eeff..1205a9c 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -566,11 +566,6 @@ function system_element_info() { $types['value'] = array( '#input' => TRUE, ); - // A "more" link, like those used in blocks. - $types['more_link'] = $types['link'] + array( - '#title' => t('More'), - '#default_attributes' => array('class' => array('more-link')), - ); $types['fieldset'] = array( '#value' => NULL, '#process' => array('form_process_group', 'ajax_process_form'),