globalScope = typeof global !== 'undefined' ? global : this,
oldGlobalMoment,
round = Math.round,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
i,
YEAR = 0,
}
}
+ function hasOwnProp(a, b) {
+ return hasOwnProperty.call(a, b);
+ }
+
function defaultParsingFlags() {
// We need to deep clone this object, and es5 standard is not very
// helpful.
function extend(a, b) {
for (var i in b) {
- if (b.hasOwnProperty(i)) {
+ if (hasOwnProp(b, i)) {
a[i] = b[i];
}
}
- if (b.hasOwnProperty('toString')) {
+ if (hasOwnProp(b, 'toString')) {
a.toString = b.toString;
}
- if (b.hasOwnProperty('valueOf')) {
+ if (hasOwnProp(b, 'valueOf')) {
a.valueOf = b.valueOf;
}
prop;
for (prop in inputObject) {
- if (inputObject.hasOwnProperty(prop)) {
+ if (hasOwnProp(inputObject, prop)) {
normalizedProp = normalizeUnits(prop);
if (normalizedProp) {
normalizedInput[normalizedProp] = inputObject[prop];
ret = new Duration(duration);
- if (moment.isDuration(input) && input.hasOwnProperty('_locale')) {
+ if (moment.isDuration(input) && hasOwnProp(input, '_locale')) {
ret._locale = input._locale;
}
// compare moment object
moment.isMoment = function (obj) {
return obj instanceof Moment ||
- (obj != null && obj.hasOwnProperty('_isAMomentObject'));
+ (obj != null && hasOwnProp(obj, '_isAMomentObject'));
};
// for typechecking Duration objects
}
for (i in unitMillisecondFactors) {
- if (unitMillisecondFactors.hasOwnProperty(i)) {
+ if (hasOwnProp(unitMillisecondFactors, i)) {
makeDurationGetter(i.toLowerCase());
}
}
test.ok(!moment.isMoment(null), 'null is not moment object');
test.ok(!moment.isMoment(undefined), 'undefined is not moment object');
+ test.done();
+ },
+
+ 'is moment with hacked hasOwnProperty': function (test) {
+ var obj = {};
+ // HACK to suppress jshint warning about bad property name
+ obj['hasOwnMoney'.replace('Money', 'Property')] = function () {
+ return true;
+ };
+
+ test.ok(!moment.isMoment(obj), 'isMoment works even if passed object has a wrong hasOwnProperty implementation (ie8)');
test.done();
}
};