-
Notifications
You must be signed in to change notification settings - Fork 33
Rerender issue #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
If anyone's using patch-package, here's the patch until it's fixed: diff --git a/node_modules/@testing-library/svelte/dist/pure.js b/node_modules/@testing-library/svelte/dist/pure.js
index 5dd914d..0d4455b 100644
--- a/node_modules/@testing-library/svelte/dist/pure.js
+++ b/node_modules/@testing-library/svelte/dist/pure.js
@@ -52,27 +52,32 @@ const render = (Component, _ref = {}, {
container = container || document.body;
target = target || container.appendChild(document.createElement('div'));
const ComponentConstructor = Component.default || Component;
- const isProps = !Object.keys(options).some(option => svleteComponentOptions.includes(option)); // Check if any props and Svelte options were accidentally mixed.
-
- if (!isProps) {
- const unrecognizedOptions = Object.keys(options).filter(option => !svleteComponentOptions.includes(option));
-
- if (unrecognizedOptions.length > 0) {
- throw Error(`
- Unknown options were found [${unrecognizedOptions}]. This might happen if you've mixed
- passing in props with Svelte options into the render function. Valid Svelte options
- are [${svleteComponentOptions}]. You can either change the prop names, or pass in your
- props for that component via the \`props\` option.\n\n
- Eg: const { /** Results **/ } = render(MyComponent, { props: { /** props here **/ } })\n\n
- `);
+
+ function checkProps(options) {
+ const isProps = !Object.keys(options).some(option => svleteComponentOptions.includes(option)); // Check if any props and Svelte options were accidentally mixed.
+
+ if (!isProps) {
+ const unrecognizedOptions = Object.keys(options).filter(option => !svleteComponentOptions.includes(option));
+
+ if (unrecognizedOptions.length > 0) {
+ throw Error(`
+ Unknown options were found [${unrecognizedOptions}]. This might happen if you've mixed
+ passing in props with Svelte options into the render function. Valid Svelte options
+ are [${svleteComponentOptions}]. You can either change the prop names, or pass in your
+ props for that component via the \`props\` option.\n\n
+ Eg: const { /** Results **/ } = render(MyComponent, { props: { /** props here **/ } })\n\n
+ `);
+ }
+
+ return options;
}
+
+ return { props: options };
}
const component = new ComponentConstructor(_objectSpread({
target
- }, isProps ? {
- props: options
- } : options));
+ }, checkProps(options)));
containerCache.set(container, {
target,
component
@@ -88,9 +93,9 @@ const render = (Component, _ref = {}, {
rerender: options => {
if (componentCache.has(component)) component.$destroy(); // eslint-disable-next-line no-new
- const newComponent = new ComponentConstructor(_objectSpread({}, options, {
+ const newComponent = new ComponentConstructor(_objectSpread({
target
- }));
+ }, checkProps(options)));
containerCache.set(container, {
target,
newComponent
|
@MirrorBytes would you mind submitting a PR with a fix for this? |
Sure, I'll submit one in a few minutes. |
🎉 This issue has been resolved in version 3.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Had to change the render function in
pure.js
to this in order to fix the error:The
_objectSpread
calls should be identical.The text was updated successfully, but these errors were encountered: