From 1ee194afa76a0eecc3bc7424f62ebdd025c9b24c Mon Sep 17 00:00:00 2001 From: Paul Cuthbertson Date: Mon, 16 Jun 2014 23:17:01 +0100 Subject: [PATCH] Fix to add constructors' static methods to proxy functions. --- extensions/DOMAPI/DOMAPI.moonshine.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/DOMAPI/DOMAPI.moonshine.js b/extensions/DOMAPI/DOMAPI.moonshine.js index 1c5867b..560b9ba 100644 --- a/extensions/DOMAPI/DOMAPI.moonshine.js +++ b/extensions/DOMAPI/DOMAPI.moonshine.js @@ -28,7 +28,8 @@ mt = new shine.Table({ __index: function (t, key) { - var property = obj[key]; + var property = obj[key], + i, children, child; // Bind methods to object and convert args and return values if (typeof property == 'function' || (property && property.prototype && typeof property.prototype.constructor == 'function')) { // KLUDGE: Safari reports native constructors as objects, not functions :-s @@ -40,6 +41,15 @@ return [retval]; }; + // Add static methods, etc + if (Object.getOwnPropertyNames) { + children = Object.getOwnPropertyNames(property); + + for (i = 0; child = children[i]; i++) { + f[child] = property[child]; + } + } + // Add a new method for instantiating classes f.new = function () { var args = convertArguments(arguments, luaToJS),