Move functions in to a higher scope

- Prevents them from accessing eq's local vars, which could cause bugs.
This commit is contained in:
Ben Christel
2016-07-19 15:02:08 -07:00
parent a0bce8031e
commit d9ded15c45

View File

@@ -231,21 +231,21 @@ getJasmineRequireObj().matchersUtil = function(j$) {
return extraKeys; return extraKeys;
} }
}
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
function has(obj, key) { function isFunction(obj) {
return Object.prototype.hasOwnProperty.call(obj, key); return typeof obj === 'function';
} }
function isFunction(obj) { function isObjectConstructor(ctor) {
return typeof obj === 'function'; // aCtor instanceof aCtor is true for the Object and Function
} // constructors (since a constructor is-a Function and a function is-a
// Object). We don't just compare ctor === Object because the constructor
function isObjectConstructor(ctor) { // might come from a different frame with different globals.
// aCtor instanceof aCtor is true for the Object and Function return isFunction(ctor) && ctor instanceof ctor;
// constructors (since a constructor is-a Function and a function is-a
// Object). We don't just compare ctor === Object because the constructor
// might come from a different frame with different globals.
return isFunction(ctor) && ctor instanceof ctor;
}
} }
}; };