-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
chore: use custom event constructor instead of deprecated #8474
chore: use custom event constructor instead of deprecated #8474
Conversation
@tronicboy1 is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
@@ -61,6 +61,7 @@ global.navigator = window.navigator; | |||
global.getComputedStyle = window.getComputedStyle; | |||
global.requestAnimationFrame = null; // placeholder, filled in using set_raf | |||
global.window = window; | |||
global.CustomEvent = window.CustomEvent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to add the CustomEvent constructor to the global context for tests.
AFAIK this is kept that way to support old browsers which don't have this global yet. For Svelte 5 I would probably in favor of moving to the new event constructor, if it can be polyfilled. |
I can understand that. Polyfilling is a can of worms I don’t think you want to open. We could add an if clause for browsers that don’t have the global CustomEvent. It’s been 3 years since the discussion for this implementation happened; now 99% of browsers support CustomEvent. It could be time to reconsider. |
It will be time to reconsider, when we are releasing a new major version of Svelte where we permit ourselves to make breaking changes. We can't just say "it's been several years, so we won't consider dropping support for these browsers a breaking change anymore". |
@Conduitry 100% agree with you, it would be a breaking change making it a major version change and I understand that now. My apologies for coming across a bit rash, it's my first time attempting to contribute here 😅. If there are other plans in place to fix some of the deprecated uses feel free to close this PR. |
…Event` method closes #8474
Problem
The
custom_event
function usesdocument.createEvent
which is a deprecated method.https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/initCustomEvent
Solution
use the constructor method,
new CustomEvent(...)
, instead.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests
npm test
and lint the project withnpm run lint