* @template {Record<string, any>} Exports * @param {ComponentType<SvelteComponent<any>> | Component<any>} Component * @param {MountOptions} options * @returns {Exports}
(
Component,
{ target, anchor, props = {}, events, context, intro = true, transformError }
)
| 160 | * @returns {Exports} |
| 161 | */ |
| 162 | function _mount( |
| 163 | Component, |
| 164 | { target, anchor, props = {}, events, context, intro = true, transformError } |
| 165 | ) { |
| 166 | init_operations(); |
| 167 | |
| 168 | /** @type {Exports} */ |
| 169 | class="cm">// @ts-expect-error will be defined because the render effect runs synchronously |
| 170 | var component = undefined; |
| 171 | |
| 172 | var unmount = component_root(() => { |
| 173 | var anchor_node = anchor ?? target.appendChild(create_text()); |
| 174 | |
| 175 | boundary( |
| 176 | /** @type {TemplateNode} */ (anchor_node), |
| 177 | { |
| 178 | pending: () => {} |
| 179 | }, |
| 180 | (anchor_node) => { |
| 181 | push({}); |
| 182 | var ctx = /** @type {ComponentContext} */ (component_context); |
| 183 | if (context) ctx.c = context; |
| 184 | |
| 185 | if (events) { |
| 186 | class="cm">// We canclass="st">'t spread the object or else we'd lose the state proxy stuff, if it is one |
| 187 | /** @type {any} */ (props).$$events = events; |
| 188 | } |
| 189 | |
| 190 | if (hydrating) { |
| 191 | assign_nodes(/** @type {TemplateNode} */ (anchor_node), null); |
| 192 | } |
| 193 | |
| 194 | should_intro = intro; |
| 195 | class="cm">// @ts-expect-error the public typings are not what the actual function looks like |
| 196 | component = Component(anchor_node, props) || {}; |
| 197 | should_intro = true; |
| 198 | |
| 199 | if (hydrating) { |
| 200 | /** @type {Effect & { nodes: EffectNodes }} */ (active_effect).nodes.end = hydrate_node; |
| 201 | |
| 202 | if ( |
| 203 | hydrate_node === null || |
| 204 | hydrate_node.nodeType !== COMMENT_NODE || |
| 205 | /** @type {Comment} */ (hydrate_node).data !== HYDRATION_END |
| 206 | ) { |
| 207 | w.hydration_mismatch(); |
| 208 | throw HYDRATION_ERROR; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | pop(); |
| 213 | }, |
| 214 | transformError |
| 215 | ); |
| 216 | |
| 217 | class="cm">// Setup event delegation _after_ component is mounted - if an error would happen during mount, it would otherwise not be cleaned up |
| 218 | /** @type {Set<string>} */ |
| 219 | var registered_events = new Set(); |
no test coverage detected