@@ -10,6 +10,8 @@ import { current_component } from './context.js';
10
10
* tag: string;
11
11
* parent: null | Element;
12
12
* filename: null | string;
13
+ * line: number;
14
+ * column: number;
13
15
* }} Element
14
16
*/
15
17
@@ -29,14 +31,15 @@ function error_on_client(payload, message) {
29
31
'which may result in content being shifted around and will likely result in a hydration mismatch.' ;
30
32
// eslint-disable-next-line no-console
31
33
console . error ( message ) ;
32
- payload . head . out += `<script>console.error(\` ${ message } \` )</script>` ;
34
+ payload . head . out += `<script>console.error(${ JSON . stringify ( message ) } )</script>` ;
33
35
}
34
36
35
37
/**
36
- * @param {string | null } file
38
+ * @param {Element } element
37
39
*/
38
- function print_file ( file ) {
39
- return file ? `(${ file } )` : '' ;
40
+ function stringify ( element ) {
41
+ if ( element . filename === null ) return `\`<${ element . tag } >\`` ;
42
+ return `\`<${ element . tag } >\` (${ element . filename } :${ element . line } :${ element . column } )` ;
40
43
}
41
44
42
45
/**
@@ -45,10 +48,7 @@ function print_file(file) {
45
48
* @param {Element } child
46
49
*/
47
50
function print_error ( payload , parent , child ) {
48
- error_on_client (
49
- payload ,
50
- `<${ child . tag } > ${ print_file ( child . filename ) } is not a valid child element of <${ parent . tag } > ${ print_file ( parent . filename ) } `
51
- ) ;
51
+ error_on_client ( payload , `${ stringify ( child ) } cannot contain ${ stringify ( parent ) } ` ) ;
52
52
}
53
53
54
54
/**
@@ -59,7 +59,7 @@ function print_error(payload, parent, child) {
59
59
*/
60
60
export function push_element ( payload , tag , line , column ) {
61
61
var filename = /** @type {import('#server').Component } */ ( current_component ) . function . filename ;
62
- var child = { tag, parent, filename } ;
62
+ var child = { tag, parent, filename, line , column } ;
63
63
64
64
if ( parent !== null && ! is_tag_valid_with_parent ( tag , parent . tag ) ) {
65
65
print_error ( payload , parent , child ) ;
0 commit comments