You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/12/23 17:18:36 UTC
ios commit: CB-4330 Fix hash changes being treated as top-level
navigations
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 <ag...@chromium.org>
Authored: Mon Dec 23 11:17:40 2013 -0500
Committer: Andrew Grieve <ag...@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];
}
}
}