From 3143f62f6185cf2fee9f20178d2c6c063184d426 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 28 Jan 2023 05:57:28 -0800 Subject: [PATCH] add comment --- src/compiler/compile/nodes/Element.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 6218032ee0..4289e948f2 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -621,7 +621,10 @@ export default class Element extends Node { const name_attribute = attribute_map.get('name'); const target_attribute = attribute_map.get('target'); - if (component.compile_options.legacy && target_attribute && target_attribute.get_static_value() === '_blank' && href_attribute) { + // links with target="_blank" should have no opener or noreferrer: https://developer.chrome.com/docs/lighthouse/best-practices/external-anchors-use-rel-noopener/ + // modern browsers add noopener by default, so we only need to check legacy browsers + // legacy browsers don't support noopener so we only check for noreferrer there + If (component.compile_options.legacy && target_attribute && target_attribute.get_static_value() === '_blank' && href_attribute) { const href_static_value = href_attribute.get_static_value() ? href_attribute.get_static_value().toLowerCase() : null; if (href_static_value === null || href_static_value.match(/^(https?:)?\/\//i)) {