Project

General

Profile

Actions

Bug #7457

closed

Adding an invisible WDateEdit and WGoogleMap causes a JavaScript error

Added by Roel Standaert almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
02/13/2020
Due date:
% Done:

0%

Estimated time:

Description

Somehow, the new WPopupWidget... JavaScript code ends up being executed before the loading of WPopupWidget.js. This seems to be related to the fact that WGoogleMap require()s some new JavaScript, causing the WPopupWidget.js code to be placed into the ScriptLibrary.beforeLoadJS.


Files

issue_7457.cpp (534 Bytes) issue_7457.cpp Test case to reproduce the issue in Wt 4 Roel Standaert, 02/13/2020 12:29 PM
issue_7457.cpp (494 Bytes) issue_7457.cpp Test case to reproduce the issue in Wt 3 Roel Standaert, 02/13/2020 12:41 PM
Actions #1

Updated by Roel Standaert almost 5 years ago

Actions #2

Updated by Roel Standaert almost 5 years ago

  • Target version set to 4.3.0
Actions #3

Updated by Roel Standaert almost 5 years ago

Actions #4

Updated by Roel Standaert almost 5 years ago

Note: this also happens when a WDateEdit and WGoogleMap are both created and added to the root at the same time when e.g. reacting to some signal.

Actions #5

Updated by Roel Standaert almost 5 years ago

So this is what I see happening:

  • LOAD_JAVASCRIPT(...) runs in WPopupWidget, adding it to WApplication::newJavaScriptToLoad_
  • setJavaScriptMember(...) runs in WPopupWidget, adding the code to run to WWebWidget::otherImpl_->jsStatements_ for that WPopupWidget
  • WGoogleMap uses WApplication::require to load the Google JavaScript API, which, through streamBeforeLoadJavaScript -> streamJavaScriptPreamble causes the LOAD_JAVASCRIPT code to be placed into beforeLoadJS for that ScriptLibrary.
  • WebRenderer::collectJS collects the JavaScript from WPopupWidget's WWebWidget::otherImpl_->jsStatements_ first (which contains new WPopupWidget)
  • Then the loadScriptLibraries code is run, which contains the declaration of WPopupWidget.

Now to figure out how things should work instead. I wonder why we're loading script libraries after collecting the JavaScript of the changes?

Actions #6

Updated by Roel Standaert almost 5 years ago

  • Status changed from New to Resolved

I pushed a commit that should fix this: WApplication::require() should not be used from the render() function, so I moved it to the constructor of WGoogleMap.

Actions #7

Updated by Roel Standaert over 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF