choojs / choo

:steam_locomotive::train: - sturdy 4kb frontend framework
https://choo.io/
MIT License
6.78k stars 595 forks source link

Hash routing opt in #667

Closed tornqvist closed 6 years ago

tornqvist commented 6 years ago

Resolves #666, resolves #440

Both newcomers as well as seasoned choo users keep stumbling over this and resolve to hackish workarounds or complex subclassing of choo.

Making hash routing opt-in, hash anchors will behave as expected as per browser defaults. By opting into hash routing hashes will be transformed to be a part of the pathname (this is the current default behavior).

Example with default new behavior: https://choo-hash-anchors.glitch.me Example with hash routing enabled: https://choo-hash-anchors-enabled.glitch.me/my/app

I ended up factoring out nanolocation as the behavior had to be duplicated for location override.

This is most definitely a breaking change.

toddself commented 6 years ago

This is a great idea. It'll need to be a semver major right?

toddself commented 6 years ago

Oops that dang close button is so close to the comment button :)

YerkoPalma commented 6 years ago

I'm not clear why this would be a major change. In what case would it be breaking stuff?

tornqvist commented 6 years ago

Since hash routing is enabled by default, changing it to be opt-in would break any app that currently relies on hashes being interpreted as part of the pathname.

goto-bus-stop commented 6 years ago

How about adding the hash option with default true in a minor release and switching to false in v7?

tornqvist commented 6 years ago

A minor version defaulting to true would be a great way of getting this out there asap. I’m currently on vacation but can resolve the conflict and change the default in a day or two.

tornqvist commented 6 years ago

I switched it around to default hash routing to true so that we can release this as a minor. Should revisit this, changing it to default to false with next major release (see #563). Merging this now.

tornqvist commented 6 years ago

v6.13.0 🎉