Skip to content

Commit f4491cd

Browse files
committed
tidy up
1 parent 6b1582c commit f4491cd

File tree

2 files changed

+12
-53
lines changed

2 files changed

+12
-53
lines changed

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -48,55 +48,6 @@ export function client_component(source, analysis, options) {
4848
scopes: analysis.template.scopes,
4949
hoisted: [b.import_all('$', 'svelte/internal/client')],
5050
node: /** @type {any} */ (null), // populated by the root node
51-
// these should be set by create_block - if they're called outside, it's a bug
52-
get before_init() {
53-
/** @type {any[]} */
54-
const a = [];
55-
a.push = () => {
56-
throw new Error('before_init.push should not be called outside create_block');
57-
};
58-
return a;
59-
},
60-
get init() {
61-
/** @type {any[]} */
62-
const a = [];
63-
a.push = () => {
64-
throw new Error('init.push should not be called outside create_block');
65-
};
66-
return a;
67-
},
68-
get update() {
69-
/** @type {any[]} */
70-
const a = [];
71-
a.push = () => {
72-
throw new Error('update.push should not be called outside create_block');
73-
};
74-
return a;
75-
},
76-
get after_update() {
77-
/** @type {any[]} */
78-
const a = [];
79-
a.push = () => {
80-
throw new Error('after_update.push should not be called outside create_block');
81-
};
82-
return a;
83-
},
84-
get template() {
85-
/** @type {any[]} */
86-
const a = [];
87-
a.push = () => {
88-
throw new Error('template.push should not be called outside create_block');
89-
};
90-
return a;
91-
},
92-
get locations() {
93-
/** @type {any[]} */
94-
const a = [];
95-
a.push = () => {
96-
throw new Error('locations.push should not be called outside create_block');
97-
};
98-
return a;
99-
},
10051
legacy_reactive_statements: new Map(),
10152
metadata: {
10253
context: {
@@ -110,7 +61,15 @@ export function client_component(source, analysis, options) {
11061
preserve_whitespace: options.preserveWhitespace,
11162
public_state: new Map(),
11263
private_state: new Map(),
113-
in_constructor: false
64+
in_constructor: false,
65+
66+
// these are set inside the `Fragment` visitor, and cannot be used until then
67+
before_init: /** @type {any} */ (null),
68+
init: /** @type {any} */ (null),
69+
update: /** @type {any} */ (null),
70+
after_update: /** @type {any} */ (null),
71+
template: /** @type {any} */ (null),
72+
locations: /** @type {any} */ (null)
11473
};
11574

11675
const module = /** @type {import('estree').Program} */ (

packages/svelte/src/compiler/phases/3-transform/client/types.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export interface ComponentClientTransformState extends ClientTransformState {
4949
namespace: Namespace;
5050
bound_contenteditable: boolean;
5151
/**
52-
* Stuff that is set within the children of one `create_block` that is relevant
53-
* to said `create_block`. Shouldn't be destructured or otherwise spread unless
54-
* inside `create_block` to keep the object reference intact (it's also nested
52+
* Stuff that is set within the children of one `Fragment` visitor that is relevant
53+
* to said fragment. Shouldn't be destructured or otherwise spread unless inside the
54+
* `Fragment` visitor to keep the object reference intact (it's also nested
5555
* within `metadata` for this reason).
5656
*/
5757
context: {

0 commit comments

Comments
 (0)