Skip to content

Commit

Permalink
refactor: revert some style changes and clean some code
Browse files Browse the repository at this point in the history
  • Loading branch information
shfx committed Feb 15, 2025
1 parent d6b3cde commit bc06d07
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions packages/playwright-ct-svelte/registerSource.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function extractParams(component) {
})
);

return {props, slots, on};
return {...props, ...slots, ...on};
}

const __pwSvelteComponentKey = Symbol('svelteComponent');
Expand All @@ -75,15 +75,9 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => {
if (!isObjectComponent(component))
throw new Error('JSX mount notation is not supported');

let {props, slots, on} = extractParams(component);

super({
target: rootElement,
props: {
...props,
...slots,
...on,
},
props: extractParams(component),
...options
});
}
Expand All @@ -106,10 +100,9 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => {
};

window.playwrightUnmount = async rootElement => {
const svelteComponent = /** @type {SvelteComponent} */ (
rootElement[__pwSvelteComponentKey]
);
if (!svelteComponent) throw new Error('Component was not mounted');
const svelteComponent = /** @type {SvelteComponent} */ (rootElement[__pwSvelteComponentKey]);
if (!svelteComponent)
throw new Error('Component was not mounted');
svelteComponent.$destroy();
delete rootElement[__pwSvelteComponentKey];
};
Expand All @@ -118,16 +111,9 @@ window.playwrightUpdate = async (rootElement, component) => {
if (!isObjectComponent(component))
throw new Error('JSX mount notation is not supported');

const svelteComponent = /** @type {SvelteComponent} */ (
rootElement[__pwSvelteComponentKey]
);
if (!svelteComponent) throw new Error('Component was not mounted');

let {props, slots, on} = extractParams(component);
const svelteComponent = /** @type {SvelteComponent} */ (rootElement[__pwSvelteComponentKey]);
if (!svelteComponent)
throw new Error('Component was not mounted');

svelteComponent.$set({
...props,
...slots,
...on,
});
svelteComponent.$set(extractParams(component));
};

0 comments on commit bc06d07

Please sign in to comment.