cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject ios commit: CB-4330 Fix hash changes being treated as top-level navigations
Date Mon, 23 Dec 2013 16:18:36 GMT
Updated Branches:
  refs/heads/master 3c6ba75e6 -> a61b2891c


CB-4330 Fix hash changes being treated as top-level navigations


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/a61b2891
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/a61b2891
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/a61b2891

Branch: refs/heads/master
Commit: a61b2891cccc9ece8c813b789d24c142173990c9
Parents: 3c6ba75
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Dec 23 11:17:40 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Dec 23 11:17:40 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVWebViewDelegate.m | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a61b2891/CordovaLib/Classes/CDVWebViewDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWebViewDelegate.m b/CordovaLib/Classes/CDVWebViewDelegate.m
index 48b710e..581089c 100644
--- a/CordovaLib/Classes/CDVWebViewDelegate.m
+++ b/CordovaLib/Classes/CDVWebViewDelegate.m
@@ -211,6 +211,12 @@ typedef enum {
         shouldLoad = [_delegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
     }
 
+    // Ignore hash changes that don't navigate to a different page.
+    if ([self request:request isFragmentIdentifierToRequest:webView.request]) {
+        VerboseLog(@"Detected hash change shouldLoad");
+        return shouldLoad;
+    }
+
     VerboseLog(@"webView shouldLoad=%d (before) state=%d loadCount=%d URL=%@", shouldLoad,
_state, _loadCount, request.URL);
 
     if (shouldLoad) {
@@ -237,14 +243,12 @@ typedef enum {
                     {
                         _loadCount = 0;
                         _state = STATE_WAITING_FOR_LOAD_START;
-                        if (![self request:request isFragmentIdentifierToRequest:webView.request])
{
-                            NSString* description = [NSString stringWithFormat:@"CDVWebViewDelegate:
Navigation started when state=%d", _state];
-                            NSLog(@"%@", description);
-                            if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)])
{
-                                NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey
: description};
-                                NSError* error = [[NSError alloc] initWithDomain:@"CDVWebViewDelegate"
code:1 userInfo:errorDictionary];
-                                [_delegate webView:webView didFailLoadWithError:error];
-                            }
+                        NSString* description = [NSString stringWithFormat:@"CDVWebViewDelegate:
Navigation started when state=%d", _state];
+                        NSLog(@"%@", description);
+                        if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)])
{
+                            NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey :
description};
+                            NSError* error = [[NSError alloc] initWithDomain:@"CDVWebViewDelegate"
code:1 userInfo:errorDictionary];
+                            [_delegate webView:webView didFailLoadWithError:error];
                         }
                     }
             }


Mime
View raw message