diff --git a/.jshint b/.jshint index 41484cf8f..871364f40 100644 --- a/.jshint +++ b/.jshint @@ -5,7 +5,7 @@ "nonew": true, "curly": true, "forin": true, - "freeze": true, + "freeze": false, "undef": true, "unused": "vars" } diff --git a/lib/models/room.js b/lib/models/room.js index c9c8b4794..51554645a 100644 --- a/lib/models/room.js +++ b/lib/models/room.js @@ -184,7 +184,7 @@ Room.prototype.addEvents = function(events, duplicateStrategy) { this.currentState.setTypingEvent(events[i]); } else if (events[i].getType() === "m.receipt") { - addReceipt(this, events[i]); + this.addReceipt(events[i]); } else { if (duplicateStrategy) { @@ -284,7 +284,8 @@ Room.prototype.addReceipt = function(event) { var self = this; utils.keys(event.getContent()).forEach(function(eventId) { utils.keys(event.getContent()[eventId]).forEach(function(receiptType) { - utils.keys(event.getContent()[eventId][receiptType]).forEach(function(userId) { + utils.keys(event.getContent()[eventId][receiptType]).forEach( + function(userId) { var receipt = event.getContent()[eventId][receiptType][userId]; if (!self._receipts[receiptType]) { self._receipts[receiptType] = {}; @@ -292,7 +293,6 @@ Room.prototype.addReceipt = function(event) { if (!self._receipts[receiptType][userId]) { self._receipts[receiptType][userId] = {}; } - var oldEventId = self._receipts[receiptType][userId].eventId; self._receipts[receiptType][userId] = { eventId: eventId, data: receipt diff --git a/lib/utils.js b/lib/utils.js index 464bebc7d..2460a02fa 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -238,7 +238,6 @@ module.exports.runPolyfills = function() { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter if (!Array.prototype.filter) { Array.prototype.filter = function(fun/*, thisArg*/) { - 'use strict'; if (this === void 0 || this === null) { throw new TypeError(); @@ -282,15 +281,15 @@ module.exports.runPolyfills = function() { var T, A, k; - if (this == null) { + if (this === null || this === undefined) { throw new TypeError(' this is null or not defined'); } - // 1. Let O be the result of calling ToObject passing the |this| + // 1. Let O be the result of calling ToObject passing the |this| // value as the argument. var O = Object(this); - // 2. Let lenValue be the result of calling the Get internal + // 2. Let lenValue be the result of calling the Get internal // method of O with the argument "length". // 3. Let len be ToUint32(lenValue). var len = O.length >>> 0; @@ -306,8 +305,8 @@ module.exports.runPolyfills = function() { T = thisArg; } - // 6. Let A be a new array created as if by the expression new Array(len) - // where Array is the standard built-in constructor with that name and + // 6. Let A be a new array created as if by the expression new Array(len) + // where Array is the standard built-in constructor with that name and // len is the value of len. A = new Array(len); @@ -321,18 +320,18 @@ module.exports.runPolyfills = function() { // a. Let Pk be ToString(k). // This is implicit for LHS operands of the in operator - // b. Let kPresent be the result of calling the HasProperty internal + // b. Let kPresent be the result of calling the HasProperty internal // method of O with argument Pk. // This step can be combined with c // c. If kPresent is true, then if (k in O) { - // i. Let kValue be the result of calling the Get internal + // i. Let kValue be the result of calling the Get internal // method of O with argument Pk. kValue = O[k]; - // ii. Let mappedValue be the result of calling the Call internal - // method of callback with T as the this value and argument + // ii. Let mappedValue be the result of calling the Call internal + // method of callback with T as the this value and argument // list containing kValue, k, and O. mappedValue = callback.call(T, kValue, k, O); @@ -363,7 +362,7 @@ module.exports.runPolyfills = function() { return A; }; } -} +}; /** * Inherit the prototype methods from one constructor into another. This is a diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index d37560599..423db86c0 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -623,5 +623,5 @@ describe("Room", function() { }); - }) + }); });