-
-
Notifications
You must be signed in to change notification settings - Fork 926
Refactor router, fixes #2505 and #2778 #3027
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
base: main
Are you sure you want to change the base?
Conversation
…ixes MithrilJS#2778 Code that sets `fireAsync` to null and uses `hashchange` when `pushState` is not supported was removed in v2.2.0. However, some of that code and comments remained.
…rilJS#2505 This ensures that the reset logic is executed even when there is an internal redirect to the default route in case of failure.
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.
While we're at it, could you just make route.set
the actual definition and just have everything call route.set
instead of setPath
?
That not only will save some more gzip size, it'll also make it so people can hack into route change and transparently wrap it for more advanced use cases like capturing previous paths for more detailed analytics.
@dead-claudia Thank you for your review comment. |
The `state` is represented as a three-valued integer, but due to the `sentinel === currentResolver` condition, a boolean state appears to be sufficient in practice. This improves code readability and further reduces the bundle size.
@dead-claudia |
Since the `state` update process has been removed, `onbeforeupdate` is no longer needed. This further reduces the bundle size.
In the `update()` function, even if the `comp` parameter is undefined, it falls back to "div". This commit slightly reduces the bundle size and optimizes the component fallback process.
I added some simple refactoring and reduced the bundle size. |
Description
This PR refactors the router code to fix two issues (#2505 and #2778).
This will make the router code a little easier to read and reduce the bundle size (8.97kB(gzipped)).
Motivation and Context
I wanted to close two router-related issues (#2505 and #2778) that had been left unresolved for a long time.
Although these issues do not seem to cause any big problems even if they are not fixed, the fixed bundle size seemed to be smaller than I had expected.
How Has This Been Tested?
npm run test
Types of changes
Checklist