diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 303b2e91228c..ca9bcb8c4e8c 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -620,17 +620,18 @@ export default class Element extends Node { if (href_static_value === null || href_static_value.match(/^(https?:)?\/\//i)) { const rel = attribute_map.get('rel'); - const rel_values = rel ? rel.get_static_value().split(' ') : []; - const expected_values = ['noreferrer']; - - expected_values.forEach(expected_value => { - if (!rel || rel && rel_values.indexOf(expected_value) < 0) { - component.warn(this, { - code: `security-anchor-rel-${expected_value}`, - message: `Security: Anchor with "target=_blank" should have rel attribute containing the value "${expected_value}"` - }); - } - }); + if (rel == null || rel.is_static) { + const rel_values = rel ? rel.get_static_value().split(' ') : []; + const expected_values = ['noreferrer']; + expected_values.forEach(expected_value => { + if (!rel || rel && rel_values.indexOf(expected_value) < 0) { + component.warn(this, { + code: `security-anchor-rel-${expected_value}`, + message: `Security: Anchor with "target=_blank" should have rel attribute containing the value "${expected_value}"` + }); + } + }); + } } } diff --git a/test/validator/samples/security-anchor-rel-noreferrer/input.svelte b/test/validator/samples/security-anchor-rel-noreferrer/input.svelte index de52d5a59604..f5361e5cfeaa 100644 --- a/test/validator/samples/security-anchor-rel-noreferrer/input.svelte +++ b/test/validator/samples/security-anchor-rel-noreferrer/input.svelte @@ -28,4 +28,6 @@ svelte website (valid) svelte website (valid) svelte website (valid) -svelte website (valid) \ No newline at end of file +svelte website (valid) + +svelte website (valid)