Skip to content

Commit

Permalink
refactor: add comments to our temporary extractParams function
Browse files Browse the repository at this point in the history
  • Loading branch information
shfx committed Mar 2, 2025
1 parent f48267c commit 42460ff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/playwright-ct-svelte/registerSource.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function isObjectComponent(component) {
function extractParams(component) {
let {props, slots, on} = component;

// Svelte5 is dropping support for old slot implementation in
// exchange for prop based snippets. They have to be of certain type
// tho. To still support strings as slots for testing purposes we
// want to convert sting to Snippet.
slots = Object.fromEntries(
Object.entries(slots ?? {}).map(([key, snippet]) => {
if(typeof snippet === "string") {
Expand All @@ -48,6 +52,9 @@ function extractParams(component) {
})
);

// To support current playwright ct "on" mounting API we want to go
// through all event names and change their names as they will be
// used as standard component properties
on = Object.fromEntries(
Object.entries(on ?? {}).map(([key, fn]) => {
return [`on${key}`, fn]
Expand Down

0 comments on commit 42460ff

Please # to comment.