Skip to content

Commit

Permalink
follow-up to #152: additional function props that should not be copie…
Browse files Browse the repository at this point in the history
…d, catch exception on func assignment (#154)
  • Loading branch information
ikreymer committed Jun 20, 2024
1 parent 4b85ee0 commit 3b832e0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/wombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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] = {
Expand Down

0 comments on commit 3b832e0

Please sign in to comment.