Hello. I want to map
document.getElementById("title").value
to
gui.title
in my ecmascript application. So I can use several implementations of
gui (html, gtk+, xul, qt, etc.)
But there's no way to reference to this "title", because it's a
primitive data type, a "String".
I've tried the following:
let title = document.getElementById("title");
gui.__defineGetter__("title", function () {return title.value;});
gui.__defineSetter__("title", function (x) {title.value = x;return x;});
But this code looks ugly and isn't abstract programming. So created
the following helper function:
function link(obj, prop, target, tprop) {
obj.__defineGetter__(prop, function () {return target[tprop];});
obj.__defineSetter__(prop, function (x) {target[tprop] = x;return x;});
}
It can be used this way:
let title = document.getElementById("title");
link(gui, "title", title, "value");
I think it would be easier if such a feature would be built-in in
ecmascript. If you know a better already-possible way, please let me
know.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss