[fix] named slots breaks svelte-ignore comments (#8105)

* [fix] Named slots breaks svelte-ignore comments

Fixes #8075

* test: add tests

* refactor

* refactor test

Co-authored-by: mojinming <mojinming@cmcm.com>
Co-authored-by: Yuichiro Yamashita <xydybaseball@gmail.com>
pull/7790/head
Ming07 2 years ago committed by GitHub
parent 4f365f0171
commit 1f021226c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -143,6 +143,8 @@ export default class InlineComponent extends Node {
children.push(slot_template);
info.children.splice(i, 1);
} else if (child.type === 'Comment' && children.length > 0) {
children[children.length - 1].children.unshift(child);
}
}

@ -0,0 +1,8 @@
<script>
import Component from './Component.svelte';
</script>
<Component>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div slot='foo' on:click>hi!</div>
</Component>

@ -0,0 +1,7 @@
<script>
import Component from './Component.svelte';
</script>
<Component>
<div slot='foo' on:click>hi!</div>
</Component>

@ -0,0 +1,17 @@
[
{
"code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": {
"character": 78,
"column": 1,
"line": 6
},
"end": {
"character": 112,
"column": 35,
"line": 6
},
"pos": 78
}
]

@ -0,0 +1,8 @@
<script>
import Component from './Component.svelte';
</script>
<Component>
<!-- svelte-ignore unrelated-warning -->
<div slot='foo' on:click>hi!</div>
</Component>

@ -0,0 +1,17 @@
[
{
"code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": {
"character": 120,
"column": 1,
"line": 7
},
"end": {
"character": 154,
"column": 35,
"line": 7
},
"pos": 120
}
]
Loading…
Cancel
Save