Last active
August 29, 2015 13:58
-
-
Save Kakadu/10353353 to your computer and use it in GitHub Desktop.
Expected: City1____ and City1____. Got: City1____ and undefined. Why when strict mode is enabled eval("images.city1") is evaluated by QML JS engine into undefined? Plain javascript object are evaluated OK (not into undefined).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.pragma library | |
var global = { | |
foo: null, | |
repaint: null, | |
p: { name: "Vasya" } | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qml: eval('images.city1') = City1____ | |
qml: eval('images.city1') = undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
Global.global.repaint = function(_a_) { | |
//console.log("OCaml repaint"); | |
//console.log("eval('images') = ", eval("images") ); | |
//console.log("eval('images').city1 = ", eval("images").city1 ); | |
console.log("eval('images.city1') = ", eval("images.city1") ); | |
//console.log("eval('Global.global.p') = ", eval("Global.global.p") ); | |
//console.log("eval('Global.global.p').name = ", eval('Global.global.p').name ); | |
//console.log("eval('Global.global.p.name') = ", eval('Global.global.p.name') ); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.1 | |
import "global.js" as Global | |
import "ocaml.js" as OCaml | |
Rectangle { | |
width: 1224; height: 600; color: "lightgray"; | |
Item { id: images; visible: false | |
property string city1: "City1____" | |
//Component.onCompleted: console.log("TextureAtlas 'images' is completed"); | |
} | |
Canvas { | |
id: mapCanvas | |
antialiasing: true | |
width: 830; height: 450; focus: true | |
onPaint: { | |
Global.global.repaint(); | |
} | |
Component.onCompleted: { | |
//console.log("MapCanvas Completed"); | |
} | |
} | |
Keys.onEscapePressed: Qt.quit() | |
Component.onCompleted: { | |
//console.log("Root.onCompleted"); | |
//console.log("eval('images') = ", eval("images") ); | |
//console.log("eval('images').city1 = ", eval("images").city1 ); | |
console.log("eval('images.city1') = ", eval("images.city1") ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment