From 48fbc7725a465ba7f1094934ee405aa87208fe94 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Thu, 20 Jun 2024 09:36:18 -0700 Subject: [PATCH] follow-up to #152: additional function props that should not be copied, catch exception on func assignment --- src/wombat.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wombat.js b/src/wombat.js index 6ef4b91..121b1bc 100755 --- a/src/wombat.js +++ b/src/wombat.js @@ -62,6 +62,8 @@ function Wombat($wbwindow, wbinfo) { this.WB_CHECK_THIS_FUNC = '_____WB$wombat$check$this$function_____'; this.WB_ASSIGN_FUNC = '_____WB$wombat$assign$function_____'; + this.SKIP_OWN_FUNC_PROPS = ['name', 'length', '__WB_is_native_func__', 'arguments', 'caller', 'callee', 'prototype']; + /** @type {function(qualifiedName: string, value: string): void} */ this.wb_setAttribute = $wbwindow.Element.prototype.setAttribute; @@ -1430,10 +1432,13 @@ Wombat.prototype.defaultProxyGet = function(obj, prop, ownProps, fnCache) { var cachedFN = fnCache[prop]; if (!cachedFN || cachedFN.original !== retVal) { const boundFn = retVal.bind(obj); - const SKIP_OWN_PROPS = ['name', 'length', '__WB_is_native_func__']; for (const ownProp of Object.getOwnPropertyNames(retVal)) { - if (!SKIP_OWN_PROPS.includes(ownProp)) { - boundFn[ownProp] = retVal[ownProp]; + if (!this.SKIP_OWN_FUNC_PROPS.includes(ownProp)) { + try { + boundFn[ownProp] = retVal[ownProp]; + } catch (e) { + // ignore + } } } fnCache[prop] = {