Commit 696e4ff5 authored by anon's avatar anon

Issue #2763211 by anon: Title attributes are overwritten by linkit_filter

parent ee79aedb
......@@ -104,7 +104,7 @@ class LinkitFilter extends FilterBase implements ContainerFactoryPluginInterface
$access = $entity->access('view', NULL, TRUE);
// Set the appropriate title attribute.
if ($this->settings['title'] && !$access->isForbidden()) {
if ($this->settings['title'] && !$access->isForbidden() && !$element->getAttribute('title')) {
$element->setAttribute('title', $entity->label());
}
......
......@@ -129,4 +129,20 @@ class LinkitFilterEntityTest extends LinkitKernelTestBase {
$this->assertLinkitFilterWithTitle($file);
}
/**
* Tests that the linkit filter do not overwrite provided title attributes.
*/
public function testTitleOverwritten() {
// Create an entity.
$entity = EntityTest::create(['name' => $this->randomMachineName()]);
$entity->save();
// Automatically set the title.
$this->filter->setConfiguration(['settings' => ['title' => 1]]);
// Make sure the title is not overwritten.
$input = '<a data-entity-type="' . $entity->getEntityTypeId() . '" data-entity-uuid="' . $entity->uuid() . '" title="Do not override">Link text</a>';
$this->assertTrue(strpos($this->process($input)->getProcessedText(), 'Do not override'), 'The filer is not overwrite the provided title attribute value.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment