#704·choo

Can I pass a rootNode to `nanohref`?

Author: m90Created Sep 4, 2019Updated Jun 23, 2020

I am trying to mount a choo application in an "application shell" that is provided by a static site generator.

I would expect the routing behavior to be limited to the scope of choo's application host, yet nanohref will try to handle all anchors being clicked.

Looking at the nanohref docs, this behavior seems to be supported by passing a second rootNode argument to the nanohref function: https://github.com/choojs/nanohref#nanohrefhandlerlocation-rootnode

Looking at how choo itself is using nanohref it looks like passing a second argument is not intended: https://github.com/choojs/nanohref#nanohrefhandlerlocation-rootnode

This leads me to two questions:

  1. Is it possible to achieve this behavior in some other way?
  2. In case no, would you accept a PR that enables passing the application root to nanohref as well? In this case I have to admit I am slightly unsure how the API for this could even look like considering how there is basically zero surface area for options in choo.