Laravel-Markdown icon indicating copy to clipboard operation
Laravel-Markdown copied to clipboard

rel="noopener noreferrer" attribute added when using extension to open links in new windows (not expected)

Open some0ne2 opened this issue 7 months ago • 0 comments

Hey folks,

first of all thanks for this lib.

When using a custom extension like:

class OpenLinksInNewWindow
{
    public function __invoke(DocumentParsedEvent $e): void
    {
        $walker = $e->getDocument()->walker();

        while ($event = $walker->next()) {
            $node = $event->getNode();

            if ($node instanceof Link && $event->isEntering()) {
                $node->data->set('attributes/target', '_blank');
            }
        }
    }

}

I can see the links are rendered like the following:

<a target="_blank" href="https://duckduckgo.com" rel="noopener noreferrer">Duck Duck Go</a>

Is there any reason why rel="noopener noreferrer" is added even if it's not directly requested by me? I know it's still fine but I just want to understand why this attribute is added as it's not defined by me.

some0ne2 avatar Jul 07 '24 16:07 some0ne2