Skip to content

Commit 6b2eb47

Browse files
committed
use full filename, basename is not very helpful. also, current_component is guaranteed to not be null
1 parent 5fd493d commit 6b2eb47

File tree

1 file changed

+6
-13
lines changed
  • packages/svelte/src/internal/server

1 file changed

+6
-13
lines changed

packages/svelte/src/internal/server/dev.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { current_component } from './context.js';
99
* @typedef {{
1010
* tag: string;
1111
* parent: null | Element;
12-
* file: string;
12+
* filename: string;
1313
* }} Element
1414
*/
1515

@@ -46,19 +46,12 @@ function print_file(file) {
4646
* @param {number} column
4747
*/
4848
export function push_element(payload, tag, line, column) {
49-
var file;
50-
51-
if (current_component !== null) {
52-
const filename = current_component.function.filename;
53-
if (filename) {
54-
file = filename.split('/').at(-1);
55-
}
56-
}
49+
var filename = /** @type {import('#server').Component} */ (current_component).function.filename;
5750

5851
if (current_element !== null && !is_tag_valid_with_parent(tag, current_element.tag)) {
5952
error_on_client(
6053
payload,
61-
`<${tag}> ${print_file(file)} is not a valid child element of <${current_element.tag}> ${print_file(current_element.file)}`
54+
`<${tag}> ${print_file(filename)} is not a valid child element of <${current_element.tag}> ${print_file(current_element.filename)}`
6255
);
6356
}
6457

@@ -68,7 +61,7 @@ export function push_element(payload, tag, line, column) {
6861
if (interactive_elements.has(element.tag)) {
6962
error_on_client(
7063
payload,
71-
`<${tag}> ${print_file(file)} is not a valid child element of <${element.tag}> ${print_file(element.file)}`
64+
`<${tag}> ${print_file(filename)} is not a valid child element of <${element.tag}> ${print_file(element.filename)}`
7265
);
7366
}
7467
element = element.parent;
@@ -81,7 +74,7 @@ export function push_element(payload, tag, line, column) {
8174
if (element.tag === 'p') {
8275
error_on_client(
8376
payload,
84-
`<${tag}> ${print_file(file)} is not a valid child element of <p> ${print_file(element.file)}`
77+
`<${tag}> ${print_file(filename)} is not a valid child element of <p> ${print_file(element.filename)}`
8578
);
8679
}
8780
element = element.parent;
@@ -91,7 +84,7 @@ export function push_element(payload, tag, line, column) {
9184
current_element = {
9285
tag,
9386
parent: current_element,
94-
file
87+
filename
9588
};
9689
}
9790

0 commit comments

Comments
 (0)