Doh. It shouldn't require nullrouter: the above snippet is based on the last commit before we gave up and tried the nullrouter idea. I think we were using 2.0.1 or 2.0.2 at the time -- it's very possible we had some local modifications to can.route, but I don't see anything like that in our git log.
Looking back through, the exact line we used was if (!can.route.attr().hasOwnProperty('route')) { ... -- this might be at fault, since the code I posted will incorrectly reject the falsey "" route in your original post.
--
I just tried this with the normal pushstate plugin, and got the expected result. Here's what I'm getting, currently using 2.0.3:
- // when the app is first loading:
- // (I'm stealing can/route/pushstate, and not touching or stealing nullrouter at all)
- can.route.bindings.pushstate.root = '/demo/';
- can.route('account/:acid', { pageName: 'account-detail', workspaceName: 'account-overview' });
- // inside my top-level app-loading control, AppLoader.init():
- can.route.ready();
- console.log('initial route = ', can.route.attr('route'), can.route.attr());
I get the following output:
- initial route = account/:acid
{ - acid: "123"
- pageName: "account-detail"
- route: "account/:acid"
- workspaceName: "account-overview" }
The extra params (pageName and workspaceName, and the "/demo/" root) are all things we have in our 'real' app. I suspect (hope?) that don't affect anything here.