summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-08-26 08:36:43 (GMT)
committerAlex Pott2015-08-26 08:36:43 (GMT)
commit6c8fe4bdb489b4594a69e92e72abcf5149511ff4 (patch)
tree6da5b5cc4b421d5f8a221fb2733e612d3eb7c0f8
parentac15de319c2d1e4c9246802299b007db3be109ff (diff)
Issue #2214241 by mortendk, mdrummond, lauriii, galooph, ShaunDychko, jjcarrion, b0unty, joelpittet, scor, amitgoyal, aboros, Manuel Garcia, hkirsman, BLadwin, hussainweb, sushilkr, emma.maria, nlisgo, yched, LewisNyman, davidhernandez, mikl, camoa, dman, dodorama: Field default markup - removing the divitis
-rw-r--r--core/includes/theme.inc13
-rw-r--r--core/lib/Drupal/Core/Field/WidgetBase.php6
-rw-r--r--core/modules/comment/src/Tests/CommentFieldsTest.php4
-rw-r--r--core/modules/editor/js/editor.formattedTextEditor.js2
-rw-r--r--core/modules/field/src/Tests/Boolean/BooleanFieldTest.php2
-rw-r--r--core/modules/field/src/Tests/DisplayApiTest.php3
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php24
-rw-r--r--core/modules/image/src/Tests/ImageFieldDisplayTest.php2
-rw-r--r--core/modules/node/node.js4
-rw-r--r--core/modules/node/src/Tests/NodeViewTest.php2
-rw-r--r--core/modules/quickedit/js/editors/plainTextEditor.js2
-rw-r--r--core/modules/rdf/rdf.module36
-rw-r--r--core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php24
-rw-r--r--core/modules/rdf/src/Tests/StandardProfileTest.php4
-rw-r--r--core/modules/search/src/Tests/SearchExcerptTest.php2
-rw-r--r--core/modules/system/css/components/field.theme.css25
-rw-r--r--core/modules/system/src/Tests/Ajax/MultiFormTest.php2
-rw-r--r--core/modules/system/src/Tests/Entity/EntityViewControllerTest.php9
-rw-r--r--core/modules/system/src/Tests/Form/RebuildTest.php2
-rw-r--r--core/modules/system/templates/field.html.twig53
-rw-r--r--core/modules/taxonomy/src/Tests/TermTest.php4
-rw-r--r--core/modules/views/src/Tests/Handler/FieldWebTest.php2
-rw-r--r--core/themes/bartik/css/components/comments.css4
-rw-r--r--core/themes/bartik/css/components/field.css52
-rw-r--r--core/themes/bartik/css/components/node.css4
-rw-r--r--core/themes/bartik/templates/field--node--field-tags.html.twig12
-rw-r--r--core/themes/classy/templates/field/field--comment.html.twig12
-rw-r--r--core/themes/classy/templates/field/field--node--created.html.twig8
-rw-r--r--core/themes/classy/templates/field/field--node--title.html.twig8
-rw-r--r--core/themes/classy/templates/field/field--node--uid.html.twig8
-rw-r--r--core/themes/classy/templates/field/field.html.twig43
31 files changed, 214 insertions, 164 deletions
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 3e74521..b3deb32 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1474,8 +1474,6 @@ function template_preprocess_region(&$variables) {
* - element: A render element representing the field.
* - attributes: A string containing the attributes for the wrapping div.
* - title_attributes: A string containing the attributes for the title.
- * - content_attributes: A string containing the attributes for the content's
- * div.
*/
function template_preprocess_field(&$variables, $hook) {
$element = $variables['element'];
@@ -1492,11 +1490,22 @@ function template_preprocess_field(&$variables, $hook) {
// readers.
$variables['label'] = $element['#title'];
+
+ // @todo Check for is_object() required due to pseudo field used in
+ // quickedit_test_entity_view_alter(). Remove this check after this is fixed
+ // in https://www.drupal.org/node/2550225.
+ $variables['multiple'] = is_object($element['#items']) ? $element['#items']->getFieldDefinition()->getFieldStorageDefinition()->isMultiple() : FALSE;
+
static $default_attributes;
if (!isset($default_attributes)) {
$default_attributes = new Attribute;
}
+ // Merge attributes when a single-value field has a hidden label.
+ if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && is_object($element['#items'][0])) {
+ $variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], (array) $element['#items'][0]->_attributes);
+ }
+
// We want other preprocess functions and the theme implementation to have
// fast access to the field item render arrays. The item render array keys
// (deltas) should always be numerically indexed starting from 0, and looping
diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php
index 356eece..a58d05c 100644
--- a/core/lib/Drupal/Core/Field/WidgetBase.php
+++ b/core/lib/Drupal/Core/Field/WidgetBase.php
@@ -128,9 +128,9 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
'#parents' => array_merge($parents, array($field_name . '_wrapper')),
'#attributes' => array(
'class' => array(
- 'field-type-' . Html::getClass($this->fieldDefinition->getType()),
- 'field-name-' . Html::getClass($field_name),
- 'field-widget-' . Html::getClass($this->getPluginId()),
+ 'field--type-' . Html::getClass($this->fieldDefinition->getType()),
+ 'field--name-' . Html::getClass($field_name),
+ 'field--widget-' . Html::getClass($this->getPluginId()),
),
),
'widget' => $elements,
diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php
index ede2e91..85d3206 100644
--- a/core/modules/comment/src/Tests/CommentFieldsTest.php
+++ b/core/modules/comment/src/Tests/CommentFieldsTest.php
@@ -84,13 +84,13 @@ class CommentFieldsTest extends CommentTestBase {
$this->drupalLogin($this->webUser);
$this->drupalGet('node/' . $node->nid->value);
- $elements = $this->cssSelect('.field-type-comment');
+ $elements = $this->cssSelect('.field--type-comment');
$this->assertEqual(2, count($elements), 'There are two comment fields on the node.');
// Delete the first comment field.
FieldStorageConfig::loadByName('node', 'comment')->delete();
$this->drupalGet('node/' . $node->nid->value);
- $elements = $this->cssSelect('.field-type-comment');
+ $elements = $this->cssSelect('.field--type-comment');
$this->assertEqual(1, count($elements), 'There is one comment field on the node.');
}
diff --git a/core/modules/editor/js/editor.formattedTextEditor.js b/core/modules/editor/js/editor.formattedTextEditor.js
index 6ad38b9..73014e8 100644
--- a/core/modules/editor/js/editor.formattedTextEditor.js
+++ b/core/modules/editor/js/editor.formattedTextEditor.js
@@ -62,7 +62,7 @@
// Store the actual value of this field. We'll need this to restore the
// original value when the user discards his modifications.
- this.$textElement = this.$el.find('.field-item').eq(0);
+ this.$textElement = this.$el.find('.field__item').eq(0);
this.model.set('originalValue', this.$textElement.html());
},
diff --git a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
index 2364a8a..31f2c05 100644
--- a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
+++ b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
@@ -115,7 +115,7 @@ class BooleanFieldTest extends WebTestBase {
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
- $this->assertRaw('<div class="field-item">' . $on . '</div>');
+ $this->assertRaw('<div class="field__item">' . $on . '</div>');
// Test if we can change the on label.
$on = $this->randomMachineName();
diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php
index 6fc8174..eff812b 100644
--- a/core/modules/field/src/Tests/DisplayApiTest.php
+++ b/core/modules/field/src/Tests/DisplayApiTest.php
@@ -119,6 +119,9 @@ class DisplayApiTest extends FieldUnitTestBase {
function testFieldItemListView() {
$items = $this->entity->get($this->fieldName);
+ \Drupal::service('theme_handler')->install(['classy']);
+ $this->config('system.theme')->set('default', 'classy')->save();
+
// No display settings: check that default display settings are used.
$build = $items->view();
$this->render($build);
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
index 3c7b9d6..c897764 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
@@ -72,6 +72,10 @@ class EntityReferenceFormatterTest extends EntityUnitTestBase {
protected function setUp() {
parent::setUp();
+ // Use Classy theme for testing markup output.
+ \Drupal::service('theme_handler')->install(['classy']);
+ $this->config('system.theme')->set('default', 'classy')->save();
+
// Grant the 'view test entity' permission.
$this->installConfig(array('user'));
Role::load(RoleInterface::ANONYMOUS_ID)
@@ -185,18 +189,14 @@ class EntityReferenceFormatterTest extends EntityUnitTestBase {
$build = $this->buildRenderArray([$this->referencedEntity, $this->unsavedReferencedEntity], $formatter);
// Test the first field item.
- $expected_rendered_name_field_1 = '<div class="field field-entity-test--name field-name-name field-type-string field-label-hidden">
- <div class="field-items">
- <div class="field-item">' . $this->referencedEntity->label() . '</div>
- </div>
-</div>
-';
- $expected_rendered_body_field_1 = '<div class="field field-entity-test--body field-name-body field-type-text field-label-above">
- <div class="field-label">Body</div>
- <div class="field-items">
- <div class="field-item"><p>Hello, world!</p></div>
- </div>
-</div>
+ $expected_rendered_name_field_1 = '
+ <div class="field field--name-name field--type-string field--label-hidden field__item">' . $this->referencedEntity->label() . '</div>
+ ';
+ $expected_rendered_body_field_1 = '
+ <div class="clearfix text-formatted field field--name-body field--type-text field--label-above">
+ <div class="field__label">Body</div>
+ <div class="field__item"><p>Hello, world!</p></div>
+ </div>
';
$renderer->renderRoot($build[0]);
$this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index 1e1d798..c4cf485 100644
--- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
@@ -337,7 +337,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->drupalGet('node/' . $node->id());
// Verify that no image is displayed on the page by checking for the class
// that would be used on the image field.
- $this->assertNoPattern('<div class="(.*?)field-name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.');
+ $this->assertNoPattern('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.');
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
diff --git a/core/modules/node/node.js b/core/modules/node/node.js
index af2ed46..ebb22ff 100644
--- a/core/modules/node/node.js
+++ b/core/modules/node/node.js
@@ -31,8 +31,8 @@
$context.find('.node-form-author').drupalSetSummary(function (context) {
var $authorContext = $(context);
- var name = $authorContext.find('.field-name-uid input').val();
- var date = $authorContext.find('.field-name-created input').val();
+ var name = $authorContext.find('.field--name-uid input').val();
+ var date = $authorContext.find('.field--name-created input').val();
return date ?
Drupal.t('By @name on @date', {'@name': name, '@date': date}) :
Drupal.t('By @name', {'@name': name});
diff --git a/core/modules/node/src/Tests/NodeViewTest.php b/core/modules/node/src/Tests/NodeViewTest.php
index c60d44a..ed400ea 100644
--- a/core/modules/node/src/Tests/NodeViewTest.php
+++ b/core/modules/node/src/Tests/NodeViewTest.php
@@ -41,7 +41,7 @@ class NodeViewTest extends NodeTestBase {
$this->assertTrue(mb_strlen($title, 'utf-8') < strlen($title), 'Title has multi-byte characters.');
$node = $this->drupalCreateNode(array('title' => $title));
$this->drupalGet($node->urlInfo());
- $result = $this->xpath('//span[contains(@class, "field-name-title")]');
+ $result = $this->xpath('//span[contains(@class, "field--name-title")]');
$this->assertEqual((string) $result[0], $title, 'The passed title was returned.');
}
diff --git a/core/modules/quickedit/js/editors/plainTextEditor.js b/core/modules/quickedit/js/editors/plainTextEditor.js
index 4e43d61..8a51fc6 100644
--- a/core/modules/quickedit/js/editors/plainTextEditor.js
+++ b/core/modules/quickedit/js/editors/plainTextEditor.js
@@ -30,7 +30,7 @@
// Store the original value of this field. Necessary for reverting
// changes.
var $textElement;
- var $fieldItems = this.$el.find('.field-item');
+ var $fieldItems = this.$el.find('.field__item');
if ($fieldItems.length) {
$textElement = this.$textElement = $fieldItems.eq(0);
}
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 0a7e1f8..245dc44 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -271,6 +271,36 @@ function rdf_preprocess_html(&$variables) {
}
/**
+ * Implements hook_preprocess_HOOK().
+ *
+ * @todo remove after https://www.drupal.org/node/2556785 is fixed.
+ */
+function rdf_preprocess_field__node(&$variables) {
+ // Just an empty hook to avoid https://www.drupal.org/node/2556785.
+}
+
+/**
+ * Implements hook_preprocess_HOOK() for UID field templates.
+ */
+function rdf_preprocess_field__node__uid(&$variables) {
+ _rdf_set_field_rel_attribute($variables);
+}
+
+/**
+ * Transforms the field property attribute into a rel attribute.
+ */
+function _rdf_set_field_rel_attribute(&$variables) {
+ // Swap the regular field property attribute and use the rel attribute
+ // instead so that it plays well with the RDFa markup when only a link is
+ // present in the field output, for example in the case of the uid field.
+ if (!empty($variables['attributes']['property'])) {
+ $variables['attributes']['rel'] = $variables['attributes']['property'];
+ unset($variables['attributes']['property']);
+ }
+}
+
+
+/**
* Implements hook_preprocess_HOOK() for node templates.
*/
function rdf_preprocess_node(&$variables) {
@@ -297,12 +327,6 @@ function rdf_preprocess_node(&$variables) {
);
}
- // Adds RDFa markup for the relation between the node and its author.
- $author_mapping = $mapping->getPreparedFieldMapping('uid');
- if (!empty($author_mapping['properties']) && $variables['display_submitted']) {
- $variables['author_attributes']['rel'] = $author_mapping['properties'];
- }
-
// Adds RDFa markup for the date.
$created_mapping = $mapping->getPreparedFieldMapping('created');
if (!empty($created_mapping) && $variables['display_submitted']) {
diff --git a/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php
index f5974bb..120d6f0 100644
--- a/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php
+++ b/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php
@@ -24,7 +24,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa(array('type' => 'number_integer'), 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is not created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content]');
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
$this->assertFalse($result);
}
@@ -32,6 +32,8 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
* Tests the integer formatter with settings.
*/
public function testIntegerFormatterWithSettings() {
+ \Drupal::service('theme_handler')->install(['classy']);
+ $this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'integer';
$formatter = array(
'type' => 'number_integer',
@@ -50,7 +52,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
$this->assertTrue($result);
}
@@ -65,7 +67,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa(array('type' => 'number_unformatted'), 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is not created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content]');
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
$this->assertFalse($result);
}
@@ -73,6 +75,8 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
* Tests the float formatter with settings.
*/
public function testFloatFormatterWithSettings() {
+ \Drupal::service('theme_handler')->install(['classy']);
+ $this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'float';
$formatter = array(
'type' => 'number_decimal',
@@ -92,7 +96,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
$this->assertTrue($result);
}
@@ -113,7 +117,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is not created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content]');
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
$this->assertFalse($result);
}
@@ -121,6 +125,8 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
* Tests the float formatter with a scale. Scale is exercised.
*/
public function testFloatFormatterWithScaleExercised() {
+ \Drupal::service('theme_handler')->install(['classy']);
+ $this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'float';
$formatter = array(
'type' => 'number_decimal',
@@ -134,7 +140,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
$this->assertTrue($result);
}
@@ -149,7 +155,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa(array('type' => 'number_decimal'), 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is not created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content]');
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
$this->assertFalse($result);
}
@@ -157,6 +163,8 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
* Tests the decimal formatter with settings.
*/
public function testDecimalFormatterWithSettings() {
+ \Drupal::service('theme_handler')->install(['classy']);
+ $this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'decimal';
$formatter = array(
'type' => 'number_decimal',
@@ -176,7 +184,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
// Test that the content attribute is created.
- $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field-item") and @content=:testValue]', array(':testValue' => $testValue));
+ $result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
$this->assertTrue($result);
}
diff --git a/core/modules/rdf/src/Tests/StandardProfileTest.php b/core/modules/rdf/src/Tests/StandardProfileTest.php
index 5036c62..57f4c3f 100644
--- a/core/modules/rdf/src/Tests/StandardProfileTest.php
+++ b/core/modules/rdf/src/Tests/StandardProfileTest.php
@@ -107,6 +107,10 @@ class StandardProfileTest extends WebTestBase {
protected function setUp() {
parent::setUp();
+ // Use Classy theme for testing markup output.
+ \Drupal::service('theme_handler')->install(['classy']);
+ $this->config('system.theme')->set('default', 'classy')->save();
+
$this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
// Create two test users.
diff --git a/core/modules/search/src/Tests/SearchExcerptTest.php b/core/modules/search/src/Tests/SearchExcerptTest.php
index 9f4a5ad2..4f14b26 100644
--- a/core/modules/search/src/Tests/SearchExcerptTest.php
+++ b/core/modules/search/src/Tests/SearchExcerptTest.php
@@ -69,7 +69,7 @@ class SearchExcerptTest extends WebTestBase {
// The node body that will produce this rendered $text is:
// 123456789 HTMLTest +123456789+&lsquo; +&lsquo; +&lsquo; +&lsquo; +12345678 &nbsp;&nbsp; +&lsquo; +&lsquo; +&lsquo; &lsquo;
- $text = "<div class=\"field field-name-body field-type-text-with-summary field-label-hidden\"><div class=\"field-items\"><div class=\"field-item even\" property=\"content:encoded\"><p>123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678    +‘ +‘ +‘ ‘</p>\n</div></div></div> ";
+ $text = "<div class=\"field field--name-body field--type-text-with-summary field--label-hidden\"><div class=\"field__items\"><div class=\"field__item even\" property=\"content:encoded\"><p>123456789 HTMLTest +123456789+‘ +‘ +‘ +‘ +12345678    +‘ +‘ +‘ ‘</p>\n</div></div></div> ";
$result = $this->doSearchExcerpt('HTMLTest', $text);
$this->assertFalse(empty($result), 'Rendered Multi-byte HTML encodings are not corrupted in search excerpts');
}
diff --git a/core/modules/system/css/components/field.theme.css b/core/modules/system/css/components/field.theme.css
index 89a16aa..0ef4c2d 100644
--- a/core/modules/system/css/components/field.theme.css
+++ b/core/modules/system/css/components/field.theme.css
@@ -3,20 +3,23 @@
* Visual styles for fields.
*/
-.field .field-label {
+.field__label {
font-weight: bold;
}
-.field-label-inline .field-label,
-.field-label-inline .field-items {
- float:left; /*LTR*/
- margin-right: 0.5em; /*LTR*/
+.field--label-inline .field__label,
+.field--label-inline .field__items {
+ float: left; /*LTR*/
}
-[dir="rtl"] .field-label-inline .field-label,
-[dir="rtl"] .field-label-inline .field-items {
- float: right;
- margin-left: 0.5em;
- margin-right: 0;
+.field--label-inline .field__label,
+.field--label-inline > .field__item,
+.field--label-inline .field__items {
+ padding-right: 0.5em;
}
-.field-label-inline .field-label::after {
+[dir="rtl"] .field--label-inline .field__label,
+[dir="rtl"] .field--label-inline .field__items {
+ padding-left: 0.5em;
+ padding-right: 0;
+}
+.field--label-inline .field__label::after {
content: ':';
}
diff --git a/core/modules/system/src/Tests/Ajax/MultiFormTest.php b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
index 5c3a60a..f87100d 100644
--- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php
+++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
@@ -60,7 +60,7 @@ class MultiFormTest extends AjaxTestBase {
$field_name = 'field_ajax_test';
$form_xpath = '//form[starts-with(@id, "node-page-form")]';
- $field_xpath = '//div[contains(@class, "field-name-field-ajax-test")]';
+ $field_xpath = '//div[contains(@class, "field--name-field-ajax-test")]';
$button_name = $field_name . '_add_more';
$button_value = t('Add another item');
$button_xpath_suffix = '//input[@name="' . $button_name . '"]';
diff --git a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
index 362f269..a80b984 100644
--- a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
@@ -46,12 +46,9 @@ class EntityViewControllerTest extends WebTestBase {
*/
function testEntityViewController() {
$get_label_markup = function($label) {
- return '<h1><div class="field field-entity-test--name field-name-name field-type-string field-label-hidden">
- <div class="field-items">
- <div class="field-item">' . $label . '</div>
- </div>
-</div>
-</h1>';
+ return '<h1>
+ <div class="field field--name-name field--type-string field--label-hidden field__item">' . $label . '</div>
+ </h1>';
};
foreach ($this->entities as $entity) {
diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php
index 9826070..ddb86ae 100644
--- a/core/modules/system/src/Tests/Form/RebuildTest.php
+++ b/core/modules/system/src/Tests/Form/RebuildTest.php
@@ -97,7 +97,7 @@ class RebuildTest extends WebTestBase {
// field items in the field for which we just added an item.
$this->drupalGet('node/add/page');
$this->drupalPostAjaxForm(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), NULL, array(), array(), 'node-page-form');
- $this->assert(count($this->xpath('//div[contains(@class, "field-name-field-ajax-test")]//input[@type="text"]')) == 2, 'AJAX submission succeeded.');
+ $this->assert(count($this->xpath('//div[contains(@class, "field--name-field-ajax-test")]//input[@type="text"]')) == 2, 'AJAX submission succeeded.');
// Submit the form with the non-Ajax "Save" button, leaving the title field
// blank to trigger a validation error, and ensure that a validation error
diff --git a/core/modules/system/templates/field.html.twig b/core/modules/system/templates/field.html.twig
index 0745f84..1b78574 100644
--- a/core/modules/system/templates/field.html.twig
+++ b/core/modules/system/templates/field.html.twig
@@ -1,7 +1,7 @@
{#
/**
* @file
- * Default theme implementation for a field.
+ * Theme override for a field.
*
* To override output, copy the "field.html.twig" from the templates directory
* to your theme's directory and customize it, just like customizing other
@@ -24,7 +24,7 @@
* - label_hidden: Whether to show the field label or not.
* - title_attributes: HTML attributes for the title.
* - label: The label for the field.
- * - content_attributes: HTML attributes for the content.
+ * - multiple: TRUE if a field can contain multiple items.
* - items: List of all the field items. Each item contains:
* - attributes: List of HTML attributes for each item.
* - content: The field item's content.
@@ -33,35 +33,34 @@
* - field_type: The type of the field.
* - label_display: The display settings for the label.
*
- * @see template_preprocess_field()
*
- * @ingroup themeable
+ * @see template_preprocess_field()
*/
#}
-{% set field_name_class = field_name|clean_class %}
-{%
- set classes = [
- 'field',
- 'field-' ~ entity_type|clean_class ~ '--' ~ field_name_class,
- 'field-name-' ~ field_name_class,
- 'field-type-' ~ field_type|clean_class,
- 'field-label-' ~ label_display,
- label_display == 'inline' ? 'clearfix',
- ]
-%}
-{%
- set title_classes = [
- 'field-label',
- label_display == 'visually_hidden' ? 'visually-hidden',
- ]
-%}
-<div{{ attributes.addClass(classes) }}>
- {% if not label_hidden %}
- <div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
+
+{% if label_hidden %}
+ {% if multiple %}
+ <div{{ attributes }}>
+ {% for item in items %}
+ <div{{ item.attributes }}>{{ item.content }}</div>
+ {% endfor %}
+ </div>
+ {% else %}
+ {% for item in items %}
+ <div{{ attributes }}>{{ item.content }}</div>
+ {% endfor %}
{% endif %}
- <div{{ content_attributes.addClass('field-items') }}>
+{% else %}
+ <div{{ attributes }}>
+ <div{{ title_attributes }}>{{ label }}</div>
+ {% if multiple %}
+ <div>
+ {% endif %}
{% for item in items %}
- <div{{ item.attributes.addClass('field-item') }}>{{ item.content }}</div>
+ <div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}
+ {% if multiple %}
+ </div>
+ {% endif %}
</div>
-</div>
+{% endif %}
diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php
index 09a0de2..3af85d8 100644
--- a/core/modules/taxonomy/src/Tests/TermTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTest.php
@@ -339,12 +339,12 @@ class TermTest extends TaxonomyTestBase {
$this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
// Did this page request display a 'term-listing-heading'?
- $this->assertTrue($this->xpath('//div[contains(@class, "field-taxonomy-term--description")]'), 'Term page displayed the term description element.');
+ $this->assertTrue($this->xpath('//div[contains(@class, "field--name-description")]'), 'Term page displayed the term description element.');
// Check that it does NOT show a description when description is blank.
$term->setDescription(NULL);
$term->save();
$this->drupalGet('taxonomy/term/' . $term->id());
- $this->assertFalse($this->xpath('//div[contains(@class, "field-taxonomy-term--description")]'), 'Term page did not display the term description when description was blank.');
+ $this->assertFalse($this->xpath('//div[contains(@class, "field--entity-taxonomy-term--description")]'), 'Term page did not display the term description when description was blank.');
// Check that the description value is processed.
$value = $this->randomMachineName();
diff --git a/core/modules/views/src/Tests/Handler/FieldWebTest.php b/core/modules/views/src/Tests/Handler/FieldWebTest.php
index 3ffec6b..0435809 100644
--- a/core/modules/views/src/Tests/Handler/FieldWebTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldWebTest.php
@@ -400,7 +400,7 @@ class FieldWebTest extends HandlerTestBase {
$output = $view->preview();
$output = $renderer->renderRoot($output);
$this->assertFalse($this->xpathContent($output, '//div[contains(@class, :class)]', array(':class' => 'field-content')));
- $this->assertFalse($this->xpathContent($output, '//div[contains(@class, :class)]', array(':class' => 'field-label')));
+ $this->assertFalse($this->xpathContent($output, '//div[contains(@class, :class)]', array(':class' => 'field__label')));
$id_field->options['element_default_classes'] = TRUE;
$output = $view->preview();
diff --git a/core/themes/bartik/css/components/comments.css b/core/themes/bartik/css/components/comments.css
index d81e63b..30e1be8 100644
--- a/core/themes/bartik/css/components/comments.css
+++ b/core/themes/bartik/css/components/comments.css
@@ -29,8 +29,8 @@
.comment__attribution img {
border: 1px solid #d3d7d9;
}
-/* This is required to win over specificity of .field-type-image img */
-.comment .field-name-user-picture img {
+/* This is required to win over specificity of .field--type-image img */
+.comment .field--name-user-picture img {
margin: 0;
}
.comment__author .username {
diff --git a/core/themes/bartik/css/components/field.css b/core/themes/bartik/css/components/field.css
index c00033a..7765348 100644
--- a/core/themes/bartik/css/components/field.css
+++ b/core/themes/bartik/css/components/field.css
@@ -3,93 +3,93 @@
* Visual styles for Bartik's field components.
*/
-.field-type-taxonomy-term-reference {
+.field--type-entity-reference {
margin: 0 0 1.2em;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
-.field-type-taxonomy-term-reference .field-label {
+.field--type-entity-reference .field__label {
font-weight: normal;
margin: 0;
padding-right: 5px; /* LTR */
}
-[dir="rtl"] .field-type-taxonomy-term-reference .field-label {
+[dir="rtl"] .field--type-entity-reference .field__label {
padding-left: 5px;
padding-right: 0;
}
-.field-type-taxonomy-term-reference .field-label,
-.field-type-taxonomy-term-reference ul.links {
+.field--type-entity-reference .field__label,
+.field--type-entity-reference ul.links {
font-size: 0.8em;
}
-.node--view-mode-teaser .field-type-taxonomy-term-reference .field-label,
-.node--view-mode-teaser .field-type-taxonomy-term-reference ul.links {
+.node--view-mode-teaser .field--type-entity-reference .field__label,
+.node--view-mode-teaser .field--type-entity-reference ul.links {
font-size: 0.821em;
}
-.field-type-taxonomy-term-reference ul.links {
+.field--type-entity-reference ul.links {
padding: 0;
margin: 0;
list-style: none;
}
-.field-type-taxonomy-term-reference ul.links li {
+.field--type-entity-reference ul.links li {
float: left; /* LTR */
padding: 0 1em 0 0; /* LTR */
white-space: nowrap;
}
-[dir="rtl"] .field-type-taxonomy-term-reference ul.links li {
+[dir="rtl"] .field--type-entity-reference ul.links li {
padding: 0 0 0 1em;
float: right;
}
@media all and (min-width: 560px) {
- .node .field-type-image {
+ .node .field--type-image {
float: left; /* LTR */
margin: 0 1em 0 0; /* LTR */
}
- [dir="rtl"] .node .field-type-image {
+ [dir="rtl"] .node .field--type-image {
float: right;
margin: 0 0 0 1em;
}
- .node .field-type-image + .field-type-image {
+ .node .field--type-image + .field--type-image {
clear: both;
}
}
-.field-type-image img,
-.field-name-field-user-picture img {
+.field--type-image img,
+.field--name-field-user-picture img {
margin: 0 0 1em;
}
-.field-type-image a {
+.field--type-image a {
border-bottom: none;
}
-.field-name-field-tags {
+.field--name-field-tags {
margin: 0 0 1.2em;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
-.field-name-field-tags .field-label {
+.field--name-field-tags .field__label {
font-weight: normal;
margin: 0;
padding-right: 5px; /* LTR */
}
-[dir="rtl"] .field-name-field-tags .field-label {
+[dir="rtl"] .field--name-field-tags .field__label {
padding-left: 5px;
padding-right: 0;
}
-.field-name-field-tags .field-label,
-.field-name-field-tags ul.links {
+.field--name-field-tags .field__label,
+.field--name-field-tags ul.links {
font-size: 0.8em;
}
-.node--view-mode-teaser .field-name-field-tags .field-label,
-.node--view-mode-teaser .field-name-field-tags ul.links {
+.node--view-mode-teaser .field--name-field-tags .field__label,
+.node--view-mode-teaser .field--name-field-tags ul.links {
font-size: 0.821em;
}
-.field-name-field-tags ul.links {
+.field--name-field-tags ul.links {
padding: 0;
margin: 0;
list-style: none;
}
-.field-name-field-tags ul.links li {
+.field--name-field-tags ul.links li {
float: left; /* LTR */
padding: 0 1em 0 0; /* LTR */
white-space: nowrap;
}
-[dir="rtl"] .field-name-field-tags ul.links li {
+[dir="rtl"] .field--name-field-tags ul.links li {
padding: 0 0 0 1em;
float: right;
}
diff --git a/core/themes/bartik/css/components/node.css b/core/themes/bartik/css/components/node.css
index dcf4ac0..e57a686 100644
--- a/core/themes/bartik/css/components/node.css
+++ b/core/themes/bartik/css/components/node.css
@@ -40,11 +40,11 @@
color: #68696b;
margin-bottom: -5px;
}
-.node__meta .field-name-field-user-picture img {
+.node__meta .field--name-field-user-picture img {
float: left; /* LTR */
margin: 1px 20px 0 0; /* LTR */
}
-[dir="rtl"] .node__meta .field-name-field-user-picture img {
+[dir="rtl"] .node__meta .field--name-field-user-picture img {
float: right;
margin-left: 20px;
margin-right: 0;
diff --git a/core/themes/bartik/templates/field--node--field-tags.html.twig b/core/themes/bartik/templates/field--node--field-tags.html.twig
index c228697..dab4094 100644
--- a/core/themes/bartik/templates/field--node--field-tags.html.twig
+++ b/core/themes/bartik/templates/field--node--field-tags.html.twig
@@ -21,20 +21,18 @@
* @see bartik_preprocess_field()
*/
#}
-{% set field_name_class = field_name|clean_class %}
{%
set classes = [
'field',
- 'field-' ~ entity_type|clean_class ~ '--' ~ field_name_class,
- 'field-name-' ~ field_name_class,
- 'field-type-' ~ field_type|clean_class,
- 'field-label-' ~ label_display,
+ 'field--name-' ~ field_name|clean_class,
+ 'field--type-' ~ field_type|clean_class,
+ 'field--label-' ~ label_display,
'clearfix',
]
%}
{%
set title_classes = [
- 'field-label',
+ 'field__label',
label_display == 'inline' ? 'inline',
]
%}
@@ -42,7 +40,7 @@
{% if not label_hidden %}
<h3{{ title_attributes.addClass(title_classes) }}>{{ label }}</h3>
{% endif %}
- <ul{{ content_attributes.addClass('links', 'field-items') }}>
+ <ul class='links field__items'>
{% for item in items %}
<li{{ item.attributes }}>{{ item.content }}</li>
{% endfor %}
diff --git a/core/themes/classy/templates/field/field--comment.html.twig b/core/themes/classy/templates/field/field--comment.html.twig
index 930c232..f797310 100644
--- a/core/themes/classy/templates/field/field--comment.html.twig
+++ b/core/themes/classy/templates/field/field--comment.html.twig
@@ -13,7 +13,6 @@
* - title_suffix: Additional title output populated by modules, intended to
* be displayed after the main title tag that appears in the template.
* - comments: List of comments rendered through comment.html.twig.
- * - content_attributes: HTML attributes for the form title.
* - comment_form: The 'Add new comment' form.
* - comment_display_mode: Is the comments are threaded.
* - comment_type: The comment type bundle ID for the comment field.
@@ -26,15 +25,12 @@
* @see comment_preprocess_field()
*/
#}
-{% set field_name_class = field_name|clean_class %}
{%
set classes = [
'field',
- 'field-' ~ entity_type|clean_class ~ '--' ~ field_name_class,
- 'field-name-' ~ field_name_class,
- 'field-type-' ~ field_type|clean_class,
- 'field-label-' ~ label_display,
- label_display == 'inline' ? 'clearfix',
+ 'field--name-' ~ field_name|clean_class,
+ 'field--type-' ~ field_type|clean_class,
+ 'field--label-' ~ label_display,
'comment-wrapper',
]
%}
@@ -54,7 +50,7 @@
{{ comments }}
{% if comment_form %}
- <h2{{ content_attributes.addClass('title', 'comment-form__title') }}>{{ 'Add new comment'|t }}</h2>
+ <h2 class='title comment-form__title'>{{ 'Add new comment'|t }}</h2>
{{ comment_form }}
{% endif %}
diff --git a/core/themes/classy/templates/field/field--node--created.html.twig b/core/themes/classy/templates/field/field--node--created.html.twig
index 6bc3939..72d5d67 100644
--- a/core/themes/classy/templates/field/field--node--created.html.twig
+++ b/core/themes/classy/templates/field/field--node--created.html.twig
@@ -19,14 +19,12 @@
* @see field.html.twig
*/
#}
-{% set field_name_class = field_name|clean_class %}
{%
set classes = [
'field',
- 'field-' ~ entity_type|clean_class ~ '--' ~ field_name_class,
- 'field-name-' ~ field_name_class,
- 'field-type-' ~ field_type|clean_class,
- 'field-label-' ~ label_display,
+ 'field--name-' ~ field_name|clean_class,
+ 'field--type-' ~ field_type|clean_class,
+ 'field--label-' ~ label_display,
]
%}
<span{{ attributes.addClass(classes) }}>
diff --git a/core/themes/classy/templates/field/field--node--title.html.twig b/core/themes/classy/templates/field/field--node--title.html.twig
index 48a732d..33b105f 100644
--- a/core/themes/classy/templates/field/field--node--title.html.twig
+++ b/core/themes/classy/templates/field/field--node--title.html.twig
@@ -19,14 +19,12 @@
* @see field.html.twig
*/
#}
-{% set field_name_class = field_name|clean_class %}
{%
set classes = [
'field',
- 'field-' ~ entity_type|clean_class ~ '--' ~ field_name_class,
- 'field-name-' ~ field_name_class,
- 'field-type-' ~ field_type|clean_class,
- 'field-label-' ~ label_display,
+ 'field--name-' ~ field_name|clean_class,
+ 'field--type-' ~ field_type|clean_class,
+ 'field--label-' ~ label_display,
]
%}
<span{{ attributes.addClass(classes) }}>
diff --git a/core/themes/classy/templates/field/field--node--uid.html.twig b/core/themes/classy/templates/field/field--node--uid.html.twig
index dcebead..a31f2b8 100644
--- a/core/themes/classy/templates/field/field--node--uid.html.twig
+++ b/core/themes/classy/templates/field/field--node--uid.html.twig
@@ -19,14 +19,12 @@
* @see field.html.twig
*/
#}
-{% set field_name_class = field_name|clean_class %}
{%
set classes = [
'field',
- 'field-' ~ entity_type|clean_class ~ '--' ~ field_name_class,
- 'field-name-' ~ field_name_class,
- 'field-type-' ~ field_type|clean_class,
- 'field-label-' ~ label_display,
+ 'field--name-' ~ field_name_class,
+ 'field--type-' ~ field_type|clean_class,
+ 'field--label-' ~ label_display,
]
%}
<span{{ attributes.addClass(classes) }}>
diff --git a/core/themes/classy/templates/field/field.html.twig b/core/themes/classy/templates/field/field.html.twig
index 5ab1e92..216fe70 100644
--- a/core/themes/classy/templates/field/field.html.twig
+++ b/core/themes/classy/templates/field/field.html.twig
@@ -24,7 +24,7 @@
* - label_hidden: Whether to show the field label or not.
* - title_attributes: HTML attributes for the title.
* - label: The label for the field.
- * - content_attributes: HTML attributes for the content.
+ * - multiple: TRUE if a field can contain multiple items.
* - items: List of all the field items. Each item contains:
* - attributes: List of HTML attributes for each item.
* - content: The field item's content.
@@ -33,33 +33,48 @@
* - field_type: The type of the field.
* - label_display: The display settings for the label.
*
+ *
* @see template_preprocess_field()
*/
#}
-{% set field_name_class = field_name|clean_class %}
{%
set classes = [
'field',
- 'field-' ~ entity_type|clean_class ~ '--' ~ field_name_class,
- 'field-name-' ~ field_name_class,
- 'field-type-' ~ field_type|clean_class,
- 'field-label-' ~ label_display,
- label_display == 'inline' ? 'clearfix',
+ 'field--name-' ~ field_name|clean_class,
+ 'field--type-' ~ field_type|clean_class,
+ 'field--label-' ~ label_display,
]
%}
{%
set title_classes = [
- 'field-label',
+ 'field__label',
label_display == 'visually_hidden' ? 'visually-hidden',
]
%}
-<div{{ attributes.addClass(classes) }}>
- {% if not label_hidden %}
- <div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
+
+{% if label_hidden %}
+ {% if multiple %}
+ <div{{ attributes.addClass(classes).addClass('field__items') }}>
+ {% for item in items %}
+ <div{{ item.attributes.addClass(classes).addClass('field__item') }}>{{ item.content }}</div>
+ {% endfor %}
+ </div>
+ {% else %}
+ {% for item in items %}
+ <div{{ attributes.addClass(classes).addClass('field__item') }}>{{ item.content }}</div>
+ {% endfor %}
{% endif %}
- <div{{ content_attributes.addClass('field-items') }}>
+{% else %}
+ <div{{ attributes.addClass(classes) }}>
+ <div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
+ {% if multiple %}
+ <div class='field__items'>
+ {% endif %}
{% for item in items %}
- <div{{ item.attributes.addClass('field-item') }}>{{ item.content }}</div>
+ <div{{ item.attributes.addClass('field__item') }}>{{ item.content }}</div>
{% endfor %}
+ {% if multiple %}
+ </div>
+ {% endif %}
</div>
-</div>
+{% endif %}