Skip to content

Commit

Permalink
chore: document init parameters (#9118)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtm-nayan authored Sep 20, 2023
1 parent 6fe17ea commit 3191147
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/svelte/src/runtime/internal/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,25 @@ function make_dirty(component, i) {
component.$$.dirty[(i / 31) | 0] |= 1 << i % 31;
}

/** @returns {void} */
// TODO: Document the other params
/**
* @param {SvelteComponent} component
* @param {import('./public.js').ComponentConstructorOptions} options
*
* @param {import('./utils.js')['not_equal']} not_equal Used to compare props and state values.
* @param {(target: Element | ShadowRoot) => void} [append_styles] Function that appends styles to the DOM when the component is first initialised.
* This will be the `add_css` function from the compiled component.
*
* @returns {void}
*/
export function init(
component,
options,
instance,
create_fragment,
not_equal,
props,
append_styles,
append_styles = null,
dirty = [-1]
) {
const parent_component = current_component;
Expand Down Expand Up @@ -139,8 +149,9 @@ export function init(
if (options.target) {
if (options.hydrate) {
start_hydrating();
// TODO: what is the correct type here?
// @ts-expect-error
const nodes = children(options.target);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
} else {
Expand Down

0 comments on commit 3191147

Please sign in to comment.