Skip to content

Commit

Permalink
Add error handling on window functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yawetse committed Jan 17, 2018
1 parent c41b0a2 commit 34ddccd
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 8 deletions.
18 changes: 16 additions & 2 deletions dist/rjx.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,23 @@ function getFunctionFromProps(options) {

if (propFunc.indexOf('func:window') !== -1) {
if (functionNameArray.length === 3) {
return window[functionNameArray[1]][functionName].bind(this);
try {
return window[functionNameArray[1]][functionName].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[functionNameArray[1]][functionName];
}
} else {
return window[functionName].bind(this);
try {
return window[functionName].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[functionName];
}
}
} else if (functionNameArray.length === 4) {
return this.props[functionNameArray[2]][functionName];
Expand Down
18 changes: 16 additions & 2 deletions dist/rjx.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,23 @@ function getFunctionFromProps(options) {

if (propFunc.indexOf('func:window') !== -1) {
if (functionNameArray.length === 3) {
return window[functionNameArray[1]][functionName].bind(this);
try {
return window[functionNameArray[1]][functionName].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[functionNameArray[1]][functionName];
}
} else {
return window[functionName].bind(this);
try {
return window[functionName].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[functionName];
}
}
} else if (functionNameArray.length === 4) {
return this.props[functionNameArray[2]][functionName];
Expand Down
18 changes: 16 additions & 2 deletions dist/rjx.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -27643,9 +27643,23 @@ function getFunctionFromProps(options) {

if (propFunc.indexOf('func:window') !== -1) {
if (functionNameArray.length === 3) {
return window[functionNameArray[1]][functionName].bind(this);
try {
return window[functionNameArray[1]][functionName].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[functionNameArray[1]][functionName];
}
} else {
return window[functionName].bind(this);
try {
return window[functionName].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[functionName];
}
}
} else if (functionNameArray.length === 4) {
return this.props[functionNameArray[2]][functionName];
Expand Down
18 changes: 16 additions & 2 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,23 @@ export function getFunctionFromProps(options) {

if (propFunc.indexOf('func:window') !== -1) {
if (functionNameArray.length === 3) {
return window[ functionNameArray[ 1 ] ][ functionName ].bind(this);
try {
return window[ functionNameArray[ 1 ] ][ functionName ].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[ functionNameArray[ 1 ] ][ functionName ];
}
} else {
return window[ functionName ].bind(this);
try {
return window[ functionName ].bind(this);
} catch (e) {
if (debug) {
logError(e);
}
return window[ functionName ];
}
}
} else if (functionNameArray.length === 4) {
return this.props[ functionNameArray[ 2 ] ][ functionName ];
Expand Down

0 comments on commit 34ddccd

Please sign in to comment.