Skip to content

Deduplicate m.route and m.redraw logic#2453

Merged
dead-claudia merged 1 commit intoMithrilJS:nextfrom
dead-claudia:route-mount-deduplicate
Jul 5, 2019
Merged

Deduplicate m.route and m.redraw logic#2453
dead-claudia merged 1 commit intoMithrilJS:nextfrom
dead-claudia:route-mount-deduplicate

Conversation

@dead-claudia
Copy link
Member

@dead-claudia dead-claudia commented Jul 5, 2019

Description

  • Remove appropriate route change subcriptions when a root is removed via m.mount(root, null).
  • Don't pollute onpopstate and friends - use standard event listeners instead.
  • Simplify and streamline subscriptions, in preparation of adding a remove parameter to m.mount.
  • Change the redraw internals to redraw immediately, with ability to cancel via returning a sentinel.
  • Change "bleeding-edge" for m.version in next to instead just be the latest m.version. (If you're using next, you should know what you're in for.)
  • Update tests to be aware of these changes. (Some were failing for subtle reasons.)
  • Drive-by: remove some uses of string.charAt(n) and use string[n] instead.

Motivation and Context

Fixes #2437.

Also, this addresses a couple things that have been in discussion for a while.

How Has This Been Tested?

Added new tests, updated a lot of tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/change-log.md

- Remove appropriate route change subcriptions when a root is removed
  via `m.mount(root, null)`.
- Don't pollute `onpopstate` and friends - use standard event listeners
  instead.
- Simplify and streamline subscriptions, in preparation of adding a
  `remove` parameter to `m.mount`.
- Change the redraw internals to redraw immediately, with ability to
  cancel via returning a sentinel.
- Change `"bleeding-edge"` for `m.version` in `next` to instead just be
  the latest `m.version`. (If you're using `next`, you should know what
  you're in for.)
- Update tests to be aware of these changes. (Some were failing for
  subtle reasons.)
- Drive-by: remove some uses of `string.charAt(n)` and use `string[n]`
  instead.
@dead-claudia dead-claudia force-pushed the route-mount-deduplicate branch from 9f6f7cf to 1603d87 Compare July 5, 2019 22:43
@dead-claudia dead-claudia merged commit 90bcff0 into MithrilJS:next Jul 5, 2019
@dead-claudia dead-claudia deleted the route-mount-deduplicate branch July 5, 2019 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Removal of mithril event listeners when navigating away from a mithril app

1 participant