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

Multi-device Hybrid App Template + WinJS = buggy single page navigation #6 #718

Closed
rachelnizh opened this issue Nov 15, 2014 · 5 comments
Closed
Assignees
Milestone

Comments

@rachelnizh
Copy link

Recreating this issue here and tagging @jayrenn so it gets looked at: microsoft/winstore-jscompat#6

@limefrogyank
Copy link

https://onedrive.live.com/redir?resid=46F246A7F6BC0008!843259&authkey=!AN8-BUNf07xgmu4&ithint=file%2czip

This is a Multi-Device Hybrid App solution that is setup for single page navigation. It currently has the winstore-jscompat.js reference commented out (in the merges/windows/scripts/platformOverrides.js file) so that it actually works.

To actually build the project for windows, you FIRST have to build it for Android to create the Debug bld folder. Then, you need to attempt to build the Windows version. It will fail with an expired key error. Follow the link below to get a new key, rename it, and copy it to the windows solution folder... build again and it will run.

https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git;a=blob;f=template/CordovaApp_TemporaryKey.pfx;h=90d7ab2208ce170d176a2ac8a60eb22fbc1cbf7a;hb=refs/tags/3.7.1

Once you see it work, then try to uncomment the winstore-jscompat stuff to see what happens... nothing :)

@pgills
Copy link
Contributor

pgills commented Nov 17, 2014

@limefrogyank So you've worked around the key issue with the following: http://msopentech.com/blog/2014/11/11/cordova-certificate-issue-were-working-on-it/ correct?

And now it seems that the winstore-jscompat shim isn't working for your application?

@limefrogyank
Copy link

Yes, the certificate issue is fine. I know how to fix that.

The winstore-jscompat.js shim is making the navigation controller fail to return a rendered page when I navigate to a page. It seems to be adding some HTML that makes whatever reads the newly-generated HTML stop reading it and silently fail. All of the scripts on the page I'm trying to navigate to are local files.

@xirzec
Copy link
Contributor

xirzec commented Dec 2, 2014

I did some digging into this. The problem is that the compat shim overrides setting innerHTML so that it cleans out unsafe things (such as script tags.)

This means that in places in WinJS where we call "setInnerHTMLUnsafe" to explicitly allow unsafe HTML, the content will still be scrubbed. Naturally, this helper is used when loading fragments, since they may contain script references.

This means that when the fragment loader tries to load your fragment, the <script> tag for your page definition gets scrubbed out when the fragment loader tries to use innerHTML.

There are a couple of workarounds:

  • Do not use the winstore-jscompat shim for WinJS apps (it's not needed)
  • Include your view pages (and any other necessary JS script) in your index.html (so in your case if you script include MainView.js in index.html your sample will work.)

It may be possible to fix this in the shim by trying to detect if you are already in "execUnsafeLocalFunction" mode or not before applying the cleaner, but I believe the only way to do this detection is to trigger an exception and catch it, which will likely have a negative impact on performance.

@xirzec
Copy link
Contributor

xirzec commented Jan 9, 2015

Fixed by 19f41cc

@xirzec xirzec closed this as completed Jan 9, 2015
@xirzec xirzec added this to the 1501 milestone Jan 9, 2015
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

5 participants