[Interest] Changes to Javascript runtime in 5.12

René Hansen renehh at gmail.com
Wed Jan 2 17:29:23 CET 2019


Hi all,


In the progress of upgrading an app to 5.12, I'm seeing some unexpected
issues with external JS dependencies.

In JS libs before 5.12, I've always used a closure approach to not leak a
bunch of private variables onto the global module object. This results in a
layout much like so:

(function(lib) {
  ... closed vars can be declared here ...

  lib.bar = function() {
    return "baz";
  };
})(this);

And then traditionally used it in QML e.g. like so:

import "foo.js" as Foo

Item {
  objectName: Foo.bar()
}

However, in 5.12 something has changed, so I can no longer assign stuff to "
*this*" in a JS library. Anything attached to the main scope comes up as
*undefined* now.

Can anyone point me in the direction of docs explaining this change, and
possibly what the preferred way of closing over variables in a JS library
is from now on?


Best regards,

René Hansen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190102/a58e62bc/attachment.html>


More information about the Interest mailing list