-
Notifications
You must be signed in to change notification settings - Fork 1
Router Questions
Create a diagram - drawio? Create the demo project and the Router package Get started
How does this work in dev tools?
It should work fine because it is driven by the state change in DomxLocation
Routerhandles body clicks- Tests all parent routes
- If matches prevents default and uses Router.pushState
- Triggers location-changed with sourceElement
DomxLocationparses the location and triggers location-changed on itselfDomxRoutepicks up the sourceElement from the location-changed event- All
DomxRouteDataelements recieve the event and update their state which includesmatches,tail,routeData,queryParamsDomxRoute- see routeStateChanged
Down is easy, they get put on the element when the location changes Up? use replaceUrlParams? this would push the params on the url then trigger location-changed
- dev tools? should work
- how does state get initialized
- Easy enough, the
Routerwill do this on initialization - test the routes and triggers location-changed
- dev tools? its initial state
- How does this work in dev tools? Should work as normal Could add a hide-when-tail boolean property to DomxRoute in case the sub route takes over the entire page
Same as above
- How does this work
- How does this work in dev tools?
There are three types of not-found behaviors all of them monitor location-changed using the domx-location. They also only have an element and an append-to attribute.
-
If declared in the root document, when location changes, it selects all domx-route elements in the DOM and if none matches it shows itself. It also monitors the route-not-found event and prevents default. If a not-found route is not declared in the root document the link clicks will not be prevented (which in some cases may be desireable)
-
If the element is inside a custom element, when the location changes, it selects all sibling routes within the shadow root (but not routes within routes) to see if none match.
-
If the element is an inline subroute it monitors checks the parents active state on location change and if active, then checks all sibling routes to see if none match.
<domx-route-not-found element="foo-bar">
<domx-route
pattern="/docs"
>
<domx-route
pattern="/readme"
></domx-route>
<domx-route-not-found element="docs-not-found" append-to="body"></domx-route-not-found>
</domx-route>