qwebchannel
Advanced tools
Comparing version 5.14.0 to 5.15.0
{ | ||
"name": "qwebchannel", | ||
"version": "5.14.0", | ||
"version": "5.15.0", | ||
"description": "Asynchronous QObject communication", | ||
@@ -5,0 +5,0 @@ "main": "qwebchannel.js", |
@@ -143,4 +143,3 @@ /**************************************************************************** | ||
{ | ||
for (var i in message.data) { | ||
var data = message.data[i]; | ||
message.data.forEach(data => { | ||
var object = channel.objects[data.object]; | ||
@@ -152,3 +151,3 @@ if (object) { | ||
} | ||
} | ||
}); | ||
channel.exec({type: QWebChannelMessageTypes.idle}); | ||
@@ -163,9 +162,11 @@ } | ||
channel.exec({type: QWebChannelMessageTypes.init}, function(data) { | ||
for (var objectName in data) { | ||
var object = new QObject(objectName, data[objectName], channel); | ||
for (const objectName of Object.keys(data)) { | ||
new QObject(objectName, data[objectName], channel); | ||
} | ||
// now unwrap properties, which might reference other registered objects | ||
for (var objectName in channel.objects) { | ||
for (const objectName of Object.keys(channel.objects)) { | ||
channel.objects[objectName].unwrapProperties(); | ||
} | ||
if (initCallback) { | ||
@@ -197,7 +198,3 @@ initCallback(channel); | ||
// support list of objects | ||
var ret = new Array(response.length); | ||
for (var i = 0; i < response.length; ++i) { | ||
ret[i] = object.unwrapQObject(response[i]); | ||
} | ||
return ret; | ||
return response.map(qobj => object.unwrapQObject(qobj)) | ||
} | ||
@@ -207,6 +204,5 @@ if (!(response instanceof Object)) | ||
if (!response["__QObject*__"] | ||
|| response.id === undefined) { | ||
if (!response["__QObject*__"] || response.id === undefined) { | ||
var jObj = {}; | ||
for (var propName in response) { | ||
for (const propName of Object.keys(response)) { | ||
jObj[propName] = object.unwrapQObject(response[propName]); | ||
@@ -234,9 +230,3 @@ } | ||
// NOTE: this detour is necessary to workaround QTBUG-40021 | ||
var propertyNames = []; | ||
for (var propertyName in qObject) { | ||
propertyNames.push(propertyName); | ||
} | ||
for (var idx in propertyNames) { | ||
delete qObject[propertyNames[idx]]; | ||
} | ||
Object.keys(qObject).forEach(name => delete qObject[name]); | ||
} | ||
@@ -251,3 +241,3 @@ }); | ||
{ | ||
for (var propertyIdx in object.__propertyCache__) { | ||
for (const propertyIdx of Object.keys(object.__propertyCache__)) { | ||
object.__propertyCache__[propertyIdx] = object.unwrapQObject(object.__propertyCache__[propertyIdx]); | ||
@@ -328,3 +318,3 @@ } | ||
// update property cache | ||
for (var propertyIndex in propertyMap) { | ||
for (const propertyIndex of Object.keys(propertyMap)) { | ||
var propertyValue = propertyMap[propertyIndex]; | ||
@@ -334,3 +324,3 @@ object.__propertyCache__[propertyIndex] = this.unwrapQObject(propertyValue); | ||
for (var signalName in signals) { | ||
for (const signalName of Object.keys(signals)) { | ||
// Invoke all callbacks, as signalEmitted() does not. This ensures the | ||
@@ -459,5 +449,3 @@ // property cache is updated before the callbacks are invoked. | ||
for (var name in data.enums) { | ||
object[name] = data.enums[name]; | ||
} | ||
Object.assign(object, data.enums); | ||
} | ||
@@ -464,0 +452,0 @@ |
18911
395