mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-19 08:01:04 +00:00
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
define(['is'], function(is) {
|
|
/**
|
|
* hasOwnProp is a shim for hasOwnProperty that is needed for Safari 2.0 support
|
|
*
|
|
* @author kangax
|
|
* @access private
|
|
* @function hasOwnProp
|
|
* @param {object} object - The object to check for a property
|
|
* @param {string} property - The property to check for
|
|
* @returns {boolean}
|
|
*/
|
|
|
|
// hasOwnProperty shim by kangax needed for Safari 2.0 support
|
|
var hasOwnProp;
|
|
|
|
(function() {
|
|
var _hasOwnProperty = ({}).hasOwnProperty;
|
|
/* istanbul ignore else */
|
|
/* we have no way of testing IE 5.5 or safari 2,
|
|
* so just assume the else gets hit */
|
|
if (!is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined')) {
|
|
hasOwnProp = function(object, property) {
|
|
return _hasOwnProperty.call(object, property);
|
|
};
|
|
}
|
|
else {
|
|
hasOwnProp = function(object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */
|
|
return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
|
|
};
|
|
}
|
|
})();
|
|
|
|
return hasOwnProp;
|
|
});
|