diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2014-04-17 14:42:15 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2014-07-03 15:28:27 +0200 |
commit | 9f78e0985d2f4fdc2588be57c5f25afdd59c6365 (patch) | |
tree | 4a413002cab91b7d10057d1430a506c47b891bb0 /src/webchannel/qwebchannel.js | |
parent | 5418f5795e2fd657efa3ceede749228c1e10d25c (diff) | |
download | qtwebchannel-9f78e0985d2f4fdc2588be57c5f25afdd59c6365.tar.gz |
Do not return a function for property getters on the HTML side.
This simplifies the usage and lets properties be used just like normal
JavaScript properties. This is possible since the properties are cached
on the HTML side.
Change-Id: Ic60076f4596cd8df063567dfbd630e5bd6403119
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'src/webchannel/qwebchannel.js')
-rw-r--r-- | src/webchannel/qwebchannel.js | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/webchannel/qwebchannel.js b/src/webchannel/qwebchannel.js index 9529c0b..278f423 100644 --- a/src/webchannel/qwebchannel.js +++ b/src/webchannel/qwebchannel.js @@ -389,24 +389,13 @@ function QObject(name, data, webChannel) }); object.__defineGetter__(propertyName, function () { - return (function (callback) { - var propertyValue = object.__propertyCache__[propertyIndex]; - if (propertyValue === undefined) { - // This shouldn't happen - console.warn("Undefined value in property cache for property \"" + propertyName + "\" in object " + object.__id__); - } + var propertyValue = object.__propertyCache__[propertyIndex]; + if (propertyValue === undefined) { + // This shouldn't happen + console.warn("Undefined value in property cache for property \"" + propertyName + "\" in object " + object.__id__); + } - // TODO: A callback is not required here anymore, but is kept for backwards compatibility - if (callback !== undefined) { - if (typeof(callback) !== "function") { - console.error("Bad callback given to get property " + property); - return; - } - callback(propertyValue); - } else { - return propertyValue; - } - }); + return propertyValue; }); } |