Skip to content

Commit eaca526

Browse files
committed
fix
1 parent 471f479 commit eaca526

File tree

1 file changed

+34
-28
lines changed
  • packages/svelte/src/internal/server

1 file changed

+34
-28
lines changed

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

+34-28
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,46 @@ import { reset_elements } from './dev.js';
2323
const INVALID_ATTR_NAME_CHAR_REGEX =
2424
/[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
2525

26+
class Payload {
27+
/** @type {Set<{ hash: string; code: string }>} */
28+
css = new Set();
29+
out = '';
30+
uid = () => '';
31+
32+
head = {
33+
/** @type {Set<{ hash: string; code: string }>} */
34+
css: new Set(),
35+
title: '',
36+
out: '',
37+
uid: () => ''
38+
};
39+
40+
constructor(id_prefix = '') {
41+
this.uid = props_id_generator(id_prefix);
42+
this.head.uid = this.uid;
43+
}
44+
}
45+
2646
/**
47+
* Used in legacy mode to handle bindings
2748
* @param {Payload} to_copy
2849
* @returns {Payload}
2950
*/
3051
export function copy_payload({ out, css, head, uid }) {
31-
return {
32-
out,
33-
css: new Set(css),
34-
head: {
35-
title: head.title,
36-
out: head.out,
37-
css: new Set(head.css),
38-
uid: head.uid
39-
},
40-
uid
52+
const payload = new Payload();
53+
54+
payload.out = out;
55+
payload.css = new Set(css);
56+
payload.uid = uid;
57+
58+
payload.head = {
59+
title: head.title,
60+
out: head.out,
61+
css: new Set(head.css),
62+
uid: head.uid
4163
};
64+
65+
return payload;
4266
}
4367

4468
/**
@@ -97,24 +121,6 @@ function props_id_generator(prefix) {
97121
return () => `${prefix}s${uid++}`;
98122
}
99123

100-
class Payload {
101-
out = '';
102-
/**@type {Set<{ hash: string; code: string }>} */
103-
css = new Set();
104-
uid = () => '';
105-
head = {
106-
/**@type {Set<{ hash: string; code: string }>} */
107-
css: new Set(),
108-
title: '',
109-
out: '',
110-
uid: () => ''
111-
};
112-
constructor(id_prefix = '') {
113-
this.uid = props_id_generator(id_prefix);
114-
this.head.uid = this.uid;
115-
}
116-
}
117-
118124
/**
119125
* Only available on the server and when compiling with the `server` option.
120126
* Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.

0 commit comments

Comments
 (0)