emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.45k stars 4.21k forks source link

Host App to Engine's Route Transition with QueryParam of type object is not working properly #16655

Open kishoreyuvan opened 6 years ago

kishoreyuvan commented 6 years ago

In my host app repository, I have an in Repo lazy loading engine.

When I proceed transition from my host app to engine's route with Query param of type object for the very first time, It shows the error like

SyntaxError: Unexpected token o in JSON at position 1

And if i do the same again, its working fine.

Actually, I found that router._queryParamsFor(handlerInfos) method in "router.js" returns the empty objects("map" and "qps") for the first time, host app tries to transtion to engine's route.

For the next time, it returns the value for the objects("map" and "qps"), this is happening becuase engine's instance is already created by the previous transition.

Also, if _queryParamsFor method returns empty object. Since, there is no type check for an object in _serializeQueryParam. It will return the string as "[object object]". .

_serializeQueryParam(value, type) {
   if (value === null || value === undefined) {
     return value;
   } else if (type === 'array') {
     return JSON.stringify(value);
   }

   return `${value}`;
 }

How can I proceed the transition to an engine route with object type QP?

Serabe commented 6 years ago

Might be related to #16664

kishoreyuvan commented 5 years ago

@pixelhandler

kindly check this https://kishoreyuvan.github.io/ember-qp-engine/