Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.0 router can't use / inside of an iframe #344

Closed
johnlindquist opened this issue Nov 28, 2016 · 7 comments
Closed

4.0.0 router can't use / inside of an iframe #344

johnlindquist opened this issue Nov 28, 2016 · 7 comments

Comments

@johnlindquist
Copy link
Contributor

4.0:
http://plnkr.co/edit/HsO6Dwtv1L4CDYi10Gv9?p=preview

3.0:
http://plnkr.co/edit/KSLgxEQveieLKWo5okxt?p=preview

In 3.0, choo properly detected the "base" route inside an iframe as /. Now in 4.0, it's forcing me to use the document.location.pathname of the iframe.

I would prefer to use / inside of iframes, but I don't know enough about routing to know if this is a bug/limitation/whatever.

@yoshuawuyts
Copy link
Member

Oh that's interesting - not entirely sure what's causing that - I think it might because of how we initialize our base route in https://github.com/yoshuawuyts/sheet-router/blob/master/create-location.js. The 4.x routing patch was intended to make apps / mobile / electron easier to use, I hadn't really considered iframes at all so thanks for reporting!

What might work (untested) is setting a base tag so it resolves correctly - https://developer.mozilla.org/en/docs/Web/HTML/Element/base - could you let me know if that perhaps works?

@johnlindquist
Copy link
Contributor Author

No luck using the base tag.

<base href="/"> won't even load the script (since the script is hosted in a /generatedkey path)

<script type="text/javascript">
      document.write("<base href='" + document.location.pathname + "' />");
</script>

loads the script, but gives me the same error as before.

@Ryuno-Ki
Copy link

Some tools moarn about base-tag not being a full-qualified URL (with protocol, subdomain and domain). Although absolute or even relative paths are valid according to the spec.

IIRC there were some differences between window.location, document.location and document.URL when it comes to iFrame …

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Apr 7, 2017

Released https://github.com/yoshuawuyts/microcomponent recently; think we're close to getting a good set of choo modules wired up in a standalone package aimed to be integrated in other libs. Most things don't need a router, so might as well make it standalone. Sooon ✨

edit: linked to the wrong package

@yoshuawuyts
Copy link
Member

So choo@6 will solve this completely, where as per #480 we'll be prototype based which means you can set your own app.router. So for iframes you could create a simple router that doesn't try and parse window.location stuff C:

@goto-bus-stop
Copy link
Member

should this be closed now that choo@6 is out?

@yoshuawuyts
Copy link
Member

@goto-bus-stop yep I think so. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants