Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27449] iOS WebView html property not set before the "load" event is fired

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterRichard Lustemberg
AssigneeShak Hossain
Created2019-09-05T14:08:32.000+0000
Updated2019-10-07T22:02:09.000+0000

Description

Since the adoption of WKWebView as a replacement for UIWebView, the "load" event no longer is triggered after the html property is set. This happens as a consequence of [(TiUIWebViewProxy *)[self proxy] refreshHTMLContent] executing asynchronously , right before the event is fired.
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
  [self _cleanupLoadingIndicator];
  [(TiUIWebViewProxy *)[self proxy] refreshHTMLContent]; //this might not be ready before the event is fired

  if ([[self proxy] _hasListeners:@"load"]) {
    [[self proxy] fireEvent:@"load" withObject:@{ @"url" : webView.URL.absoluteString, @"title" : webView.title }];
  }
}
My suggestion is to provide a completion handler argument to TiUIWebViewProxy refreshHTMLContent and fire the event from there. I can provide a PR if needed. Not having the html property set before the load event breaks the behaviour from TiUIWebView.

Comments

  1. Vijay Singh 2019-09-12

    [~rlustemberg] Thanks for raising the issue. PR with test case is always appreciated :). Thanks!
  2. Richard Lustemberg 2019-09-19

    I've missed your reply. I'll do that shortly

JSON Source