Skip to content

Commit

Permalink
IE 8 doesn't support defineProperty on non-DOM nodes, skip that kin…
Browse files Browse the repository at this point in the history
…dof thing
  • Loading branch information
Gregg Van Hove committed Oct 27, 2015
1 parent 77514bb commit ea4c449
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions spec/core/SpyRegistrySpec.js
Expand Up @@ -38,6 +38,9 @@ describe("SpyRegistry", function() {
});

it("checks if it can be spied upon", function() {
// IE 8 doesn't support `definePropery` on non-DOM nodes
if (jasmine.getEnv().ieVersion < 9) { return; }

var scope = {};

function myFunc() {
Expand Down
8 changes: 7 additions & 1 deletion src/core/SpyRegistry.js
Expand Up @@ -22,7 +22,13 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
throw new Error(methodName + ' has already been spied upon');
}

var descriptor = Object.getOwnPropertyDescriptor(obj, methodName);
var descriptor = undefined;
try {
descriptor = Object.getOwnPropertyDescriptor(obj, methodName);
} catch(e) {
// IE 8 doesn't support `definePropery` on non-DOM nodes
}

if (descriptor && !(descriptor.writable || descriptor.set)) {
throw new Error(methodName + ' is not declared writable or has no setter');
}
Expand Down

0 comments on commit ea4c449

Please sign in to comment.