Browse Source

feat(iOS WKWebView): Add mainDocumentURL to onShouldStartLoadWithRequest(#493)

* Pass mainDocumentURL to onShouldStartLoadWithRequest

* Update reference

* Update typescript types

* Update WebViewTypes.ts
Penar Musaraj 5 years ago
parent
commit
71d1fcc675
4 changed files with 4 additions and 0 deletions
  1. 1
    0
      docs/Reference.md
  2. 1
    0
      ios/RNCUIWebView.m
  3. 1
    0
      ios/RNCWKWebView.m
  4. 1
    0
      src/WebViewTypes.ts

+ 1
- 0
docs/Reference.md View File

496
 canGoBack
496
 canGoBack
497
 canGoForward
497
 canGoForward
498
 lockIdentifier
498
 lockIdentifier
499
+mainDocumentURL (iOS only)
499
 navigationType
500
 navigationType
500
 ```
501
 ```
501
 
502
 

+ 1
- 0
ios/RNCUIWebView.m View File

214
     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
214
     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
215
     [event addEntriesFromDictionary: @{
215
     [event addEntriesFromDictionary: @{
216
       @"url": (request.URL).absoluteString,
216
       @"url": (request.URL).absoluteString,
217
+      @"mainDocumentURL": (request.mainDocumentURL).absoluteString,
217
       @"navigationType": navigationTypes[@(navigationType)]
218
       @"navigationType": navigationTypes[@(navigationType)]
218
     }];
219
     }];
219
     if (![self.delegate webView:self
220
     if (![self.delegate webView:self

+ 1
- 0
ios/RNCWKWebView.m View File

721
     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
721
     NSMutableDictionary<NSString *, id> *event = [self baseEvent];
722
     [event addEntriesFromDictionary: @{
722
     [event addEntriesFromDictionary: @{
723
       @"url": (request.URL).absoluteString,
723
       @"url": (request.URL).absoluteString,
724
+      @"mainDocumentURL": (request.mainDocumentURL).absoluteString,
724
       @"navigationType": navigationTypes[@(navigationType)]
725
       @"navigationType": navigationTypes[@(navigationType)]
725
     }];
726
     }];
726
     if (![self.delegate webView:self
727
     if (![self.delegate webView:self

+ 1
- 0
src/WebViewTypes.ts View File

104
     | 'reload'
104
     | 'reload'
105
     | 'formresubmit'
105
     | 'formresubmit'
106
     | 'other';
106
     | 'other';
107
+  mainDocumentURL?: string;
107
 }
108
 }
108
 
109
 
109
 export type DecelerationRateConstant = 'normal' | 'fast';
110
 export type DecelerationRateConstant = 'normal' | 'fast';