Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
5.13.0
Description
Hello,
recently I've bumped into non-standard JS engine behavior regarding Object scope that I could not find described neither in Qt Docs, nor in this bugtracker. Here is an example:
var someFn1 = function () {}; function someFn2 () {}; var someObject = { someFn1: function() { console.log(this.someFn1 === someFn1) }, someFn2: function() { console.log(this.someFn2 === someFn2) } } someObject.someFn1(); someObject.someFn2();
As per ES6 (and earlier versions) i expect both calls to result in console messages, both saying "false", but QML's Javascript engine clearly injects somehow inner someFn declarations into this very someObject block. I guess, that could be handy (everyone is annoyed with and often forgets "this." part), but now you can't reference an outside function with same name (and you will also get an error if the outside one is declared as const). Very unfortunately, third-party libs (that are valid in terms of ES6 syntax and otherwise fully supported by your Javascript engine) will also fail. Can you please clarify if it is a bug or a feature? It would be also great to have a quick note about that part in docs. Thanks a lot.
Attachments
Issue Links
- duplicates
-
QTBUG-77015 QML 'this' property binding is broken
- Closed