Skip to content

Commit

Permalink
frontend: remove unnecessary JSON.{parse,stringify}
Browse files Browse the repository at this point in the history
  • Loading branch information
terrablue committed Nov 29, 2023
1 parent f6ff4c0 commit 1fdf2b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/frontend/src/frontends/react/client/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export default ({ names, data, context, request }, options) => `
const root = hydrateRoot(globalThis.window.document.body,
createElement(components.${rootname}, {
components: [${names.map(name => `components.${name}`).join(", ")}],
data: JSON.parse(${JSON.stringify(JSON.stringify(data))}),
context: JSON.parse(${JSON.stringify(JSON.stringify(context))}),
data: ${JSON.stringify(data)},
context: ${JSON.stringify(context)},
request: {
...JSON.parse(${JSON.stringify(JSON.stringify(request))}),
...${JSON.stringify(request)},
url: new URL(location.href),
},
})
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/frontends/solid/client/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export default ({ names, data, context, request }, options) => `
SolidHead.clear();
let dispose = hydrate_solid(() => components.${rootname}({
components: [${names.map(name => `components.${name}`).join(", ")}],
data: JSON.parse(${JSON.stringify(JSON.stringify(data))}),
context: JSON.parse(${JSON.stringify(JSON.stringify(context))}),
data: ${JSON.stringify(data)},
context: ${JSON.stringify(context)},
request: {
...JSON.parse(${JSON.stringify(JSON.stringify(request))}),
...${JSON.stringify(request)},
url: new URL(location.href),
},
}), globalThis.window.document.body);
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/frontends/svelte/client/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export default ({ names, data, context, request }, options) => `
hydrate: true,
props: {
components: [${names.map(name => `components.${name}`).join(", ")}],
data: JSON.parse(${JSON.stringify(JSON.stringify(data))}),
context: JSON.parse(${JSON.stringify(JSON.stringify(context))}),
data: ${JSON.stringify(data)},
context: ${JSON.stringify(context)},
request: {
...JSON.parse(${JSON.stringify(JSON.stringify(request))}),
...${JSON.stringify(request)},
url: new URL(location.href),
},
},
Expand Down

0 comments on commit 1fdf2b0

Please sign in to comment.