You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Kyung-man Kwak <de...@gmail.com> on 2014/10/17 08:18:11 UTC

XHRHelper.cs has problems in hash changes.

Dear cordova developers,

I have several problem in following environment.

*Environment :*

   - *Cordova 3.6.3*
   - *platform : wp8*
   - *AngularJS v1.2.6*


*Problems :*

   - anchor tag
   - ng-href or href is not working. A simple url is working, but it is not
      working when only hash part is changed in the previous url.
   - angulerjs routing
      - it is working with param "template" (this is template string).
      - it is not working with param "tempalteUrl" (this is just url of
      template)
   - angularjs $location.url(~~)
      - it is ok before getting template. it is blocked in $http which is
      for getting template.


*Reason : *

   - in my guess, XHRHelper.cs file has a problem.
   - the variable script in this file is reloaded every time url is changed
   including hash change. And variable __XHRShimAliases is also initialized at
   this time. So, __onXHRLocalCallback function is not properly working.


*My temporary solution :*

1. add following code in module config

  $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel|x-wmapp0):/);
  $locationProvider.html5Mode(false);

2. In XHRHelper.cs file(
https://apache.googlesource.com/cordova-wp8/+/3.6.x/wp8/template/cordovalib/XHRHelper.cs),
I added following code in the first line of script.

...
string script = @"(function(win, doc) {
    if (window.XHRHelperInitialized) {
         return;
     }
      window.XHRHelperInitialized = true;

     var __XHRShimAliases = {};
...

I hope this issue is patched next version. :)

Thank you for reading this issue.

Kyungman Kwak.