Problem/Motivation
#1867518: Leverage entityDisplay to provide fast rendering for fields added the following piece of code:
foreach ($field_names as $field_name) {
+ if ($entity->hasField($field_name)) {
+ foreach ($entity->get($field_name) as $item) {
+ $item->_attributes = array();
+ }
+ }
+ }
$this->fieldOutput[$entity->id()] = $displays[$bundle]->build($entity, $bundle_fields[$bundle]);
It should better not have to do that.
Proposed resolution
Add _attributes in $display->build
directly