drive by fixes

pull/7800/head
Simon H 3 years ago committed by GitHub
parent b65d94d388
commit 8e7eeada2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -471,28 +471,22 @@ function get_element_parent(node: Element): Element | null {
} }
/** /**
* Finds the given node's previous sibling in the DOM * Finds the given node's previous sibling in the DOM
* *
* Unless the component is a custom element (web component), which in this * The Svelte <slot> is just a placeholder and is not actually real. Any children nodes
* case, the <slot> element is actually real, the Svelte <slot> is just a * in <slot> are 'flattened' and considered as the same level as the <slot>'s siblings
* placeholder and is not actually real. Any children nodes in <slot> *
* are 'flattened' and considered as the same level as the <slot>'s siblings * e.g.
* * <h1>Heading 1</h1>
* e.g. * <slot>
* <h1>Heading 1</h1> * <h2>Heading 2</h2>
* <slot> * </slot>
* <h2>Heading 2</h2> *
* </slot> * is considered to look like:
* * <h1>Heading 1</h1>
* is considered to look like: * <h2>Heading 2</h2>
* <h1>Heading 1</h1> */
* <h2>Heading 2</h2>
*/
function find_previous_sibling(node: INode): INode { function find_previous_sibling(node: INode): INode {
if (node.component.compile_options.customElement) {
return node.prev;
}
let current_node: INode = node; let current_node: INode = node;
do { do {
if (current_node.type === 'Slot') { if (current_node.type === 'Slot') {

@ -8,13 +8,13 @@
</slot> </slot>
<style> <style>
/* This will not get picked up */ /* This will not be picked up */
h1 ~ p { h1 ~ slot > p {
color: red; color: red;
} }
/* This will be picked up */ /* This will get picked up */
h1 ~ slot > p { h1 ~ p {
color: red; color: red;
} }
</style> </style>

@ -1,7 +1,7 @@
[ [
{ {
"code": "css-unused-selector", "code": "css-unused-selector",
"message": "Unused CSS selector \"h1 ~ p\"", "message": "Unused CSS selector \"h1 ~ slot > p\"",
"start": { "start": {
"column": 1, "column": 1,
"line": 12 "line": 12

@ -7,12 +7,12 @@
<style> <style>
/* This will not be picked up */ /* This will not be picked up */
h1 + span { h1 + slot > span {
color: red; color: red;
} }
/* This will be picked up */ /* This will be picked up */
h1 + slot > span { h1 + span {
color: red; color: red;
} }
</style> </style>

@ -5,7 +5,7 @@
"column": 11, "column": 11,
"line": 10 "line": 10
}, },
"message": "Unused CSS selector \"h1 + span\"", "message": "Unused CSS selector \"h1 + slot > span\"",
"start": { "start": {
"column": 2, "column": 2,
"line": 10 "line": 10

Loading…
Cancel
Save