diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index 96416fe9345ebdf237335fb4e38cbc920b221fa5..64d6fc73be80cdb01125d5e601e15f5a4cae7732 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -1248,10 +1248,7 @@ public function renderText($alter) { if ($alter['phase'] == static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty) { // If we got here then $alter contains the value of "No results text" // and so there is nothing left to do. - if ($value_is_safe) { - $value = ViewsRenderPipelineMarkup::create($value); - } - return $value; + return ViewsRenderPipelineMarkup::create($value); } if (!empty($alter['strip_tags'])) { diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php index 98dcb1de69657d0d9bd4276049429936d7da11a2..66ba20783af3e6506618509e9834c2e166dde47b 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php @@ -258,6 +258,23 @@ public function testRenderTrimmedWithMoreLink() { $this->assertEquals($expected_result, $result); } + /** + * Tests the "No results text" rendering. + * + * @covers ::renderText + */ + public function testRenderNoResult() { + $this->setupDisplayWithEmptyArgumentsAndFields(); + $field = $this->setupTestField(['empty' => 'This <strong>should work</strong>.']); + $field->field_alias = 'key'; + $row = new ResultRow(['key' => '']); + + $expected_result = 'This <strong>should work</strong>.'; + $result = $field->advancedRender($row); + $this->assertEquals($expected_result, $result); + $this->assertInstanceOf('\Drupal\views\Render\ViewsRenderPipelineMarkup', $result); + } + /** * Test rendering of a link with a path and options. *