Skip to content

Commit 3143f62

Browse files
authored
add comment
1 parent cd98d0a commit 3143f62

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/compiler/compile/nodes/Element.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,10 @@ export default class Element extends Node {
621621
const name_attribute = attribute_map.get('name');
622622
const target_attribute = attribute_map.get('target');
623623

624-
if (component.compile_options.legacy && target_attribute && target_attribute.get_static_value() === '_blank' && href_attribute) {
624+
// links with target="_blank" should have no opener or noreferrer: https://developer.chrome.com/docs/lighthouse/best-practices/external-anchors-use-rel-noopener/
625+
// modern browsers add noopener by default, so we only need to check legacy browsers
626+
// legacy browsers don't support noopener so we only check for noreferrer there
627+
If (component.compile_options.legacy && target_attribute && target_attribute.get_static_value() === '_blank' && href_attribute) {
625628
const href_static_value = href_attribute.get_static_value() ? href_attribute.get_static_value().toLowerCase() : null;
626629

627630
if (href_static_value === null || href_static_value.match(/^(https?:)?\/\//i)) {

0 commit comments

Comments
 (0)