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
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to