mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 18:52:39 +03:00
6dfc0f1486
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
31 lines
705 B
JavaScript
31 lines
705 B
JavaScript
/*
|
|
* Generics for Duktape binding in NetSurf
|
|
*
|
|
* The result of this *MUST* be setting a NetSurf object only.
|
|
*
|
|
* That object will then be absorbed into the global object as a hidden
|
|
* object which is used by the rest of the bindings.
|
|
*/
|
|
|
|
var NetSurf = {
|
|
/* The make-proxy call for list-type objects */
|
|
makeListProxy: function(inner) {
|
|
return new Proxy(inner, {
|
|
has: function(target, key) {
|
|
if (typeof key == 'number') {
|
|
return (key >= 0) && (key < target.length);
|
|
} else {
|
|
return key in target;
|
|
}
|
|
},
|
|
get: function(target, key) {
|
|
if (typeof key == 'number') {
|
|
return target.item(key);
|
|
} else {
|
|
return target[key];
|
|
}
|
|
},
|
|
});
|
|
},
|
|
};
|