Closed antony closed 4 years ago
To be honest: I don't feel great about removing arguments
from the codebase simply to fix an issue you're having with babel.
@6eDesign It should be removed because it isn't used in the codebase anyway, the only caller of the once
argument doesn't pass any arguments.
It's also a strict mode violation, so when es6 is compiled to strict mode ES5, arguments is technically disallowed. It's better to have explicit arguments anyway, if there were any arguments to pass.
Not removing it will mean that nobody who transpiles their codebase for older browsers will be able to use svelte-calendar.
I think you're incorrect about arguments being disallowed in strict mode. See the relevant docs here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
Once is a function that accepts another function as a parameter. It's only used, right now, for a function that doesn't have arguments but that can change in the future. Furthermore, AFAIK, arguments is perfectly valid JS (and is used in many libraries) and I don't like the idea of banning it from the codebase.
I'd speculate that the issue you're having has nothing to do with svelte-calendar. It likely has something to do with Babel or the way you've configured Babel and the fix should lie elsewhere, in my opinion.
@6eDesign Alright, I'll crack on with it and see if I can find a workaround.
@antony great, if you do find a workaround please share. If you can't find a workaround, maybe we could at least update the code to use ...args
instead of making the once
function unusable for functions that need arguments.
Updated to use args.
After a fair bit of investigation, I think the issue was a combination of Svelte 3.19.1 and Babel 7. It seems that Svelte 3.19.2 fixes it (but I have no idea why)
I don't know why this is suddenly happening, but there is no need to use
arguments
anyway - the method is only used in one place, so we know the arguments.