Skip to content

Commit cebd1dc

Browse files
committed
🚿 strict equals
1 parent 826a5f1 commit cebd1dc

21 files changed

+129
-102
lines changed

ext/update_helper/prototype_update_helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ var prototypeUpdateHelper = new UpdateHelper([
359359
};
360360

361361
function notify(property, value){
362-
var message = messages[arguments.length == 1 ? 'getting' : 'setting'].evaluate({
362+
var message = messages[arguments.length === 1 ? 'getting' : 'setting'].evaluate({
363363
property: property,
364364
value : Object.inspect(value),
365365
});
@@ -385,7 +385,7 @@ var prototypeUpdateHelper = new UpdateHelper([
385385
function checkProperties(hash){
386386
storeProperties(hash);
387387
var current = Object.keys(hash);
388-
if(current.length == hash.__properties.length){
388+
if(current.length === hash.__properties.length){
389389
return;
390390
}
391391
current.each(function(prop){
@@ -420,7 +420,7 @@ var prototypeUpdateHelper = new UpdateHelper([
420420

421421
$H(Hash.prototype).each(function(method){
422422
var key = method.key;
423-
if(!Object.isFunction(method.value) || key == 'initialize'){
423+
if(!Object.isFunction(method.value) || key === 'initialize'){
424424
return;
425425
}
426426
Hash.prototype[key] = Hash.prototype[key].wrap(function(proceed){

ext/update_helper/update_helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ var UpdateHelper = Class.create({
7777
},
7878

7979
log: function(message, type){
80-
if(type == 'error'){
80+
if(type === 'error'){
8181
console.error(message);
8282
}
83-
else if(type == 'warn'){
83+
else if(type === 'warn'){
8484
console.warn(message);
8585
}
8686
else{

src/prototype/ajax/periodical_updater.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
246246

247247
updateComplete: function(response){
248248
if(this.options.decay){
249-
this.decay = (response.responseText == this.lastText ?
250-
this.decay * this.options.decay : 1);
249+
this.decay = response.responseText === this.lastText
250+
? this.decay * this.options.decay
251+
: 1;
251252

252253
this.lastText = response.responseText;
253254
}

src/prototype/ajax/request.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Ajax.Request = Class.create(Ajax.Base, {
229229

230230
onStateChange: function(){
231231
var readyState = this.transport.readyState;
232-
if(readyState > 1 && !((readyState == 4) && this._complete)){
232+
if(readyState > 1 && !(readyState === 4 && this._complete)){
233233
this.respondToReadyState(this.transport.readyState);
234234
}
235235
},
@@ -260,7 +260,7 @@ Ajax.Request = Class.create(Ajax.Base, {
260260
}
261261

262262
// user-defined headers
263-
if(typeof this.options.requestHeaders == 'object'){
263+
if(typeof this.options.requestHeaders === 'object'){
264264
var extras = this.options.requestHeaders;
265265

266266
if(Object.isFunction(extras.push)){
@@ -277,7 +277,7 @@ Ajax.Request = Class.create(Ajax.Base, {
277277

278278
// skip null or undefined values
279279
for(var name in headers){
280-
if(headers[name] != null){
280+
if(headers[name] !== undefined && headers[name] !== null){
281281
this.transport.setRequestHeader(name, headers[name]);
282282
}
283283
}
@@ -290,7 +290,7 @@ Ajax.Request = Class.create(Ajax.Base, {
290290
**/
291291
success: function(){
292292
var status = this.getStatus();
293-
return !status || (status >= 200 && status < 300) || status == 304;
293+
return !status || (status >= 200 && status < 300) || status === 304;
294294
},
295295

296296
getStatus: function(){
@@ -309,7 +309,7 @@ Ajax.Request = Class.create(Ajax.Base, {
309309
respondToReadyState: function(readyState){
310310
var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
311311

312-
if(state == 'Complete'){
312+
if(state === 'Complete'){
313313
try{
314314
this._complete = true;
315315
(this.options['on' + response.status]
@@ -321,7 +321,7 @@ Ajax.Request = Class.create(Ajax.Base, {
321321
}
322322

323323
var contentType = response.getHeader('Content-type');
324-
if(this.options.evalJS == 'force'
324+
if(this.options.evalJS === 'force'
325325
|| (this.options.evalJS && this.isSameOrigin() && contentType
326326
&& contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){
327327
this.evalResponse();
@@ -338,15 +338,15 @@ Ajax.Request = Class.create(Ajax.Base, {
338338
Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
339339
}
340340

341-
if(state == 'Complete'){
341+
if(state === 'Complete'){
342342
// avoid memory leak in MSIE: clean up
343343
this.transport.onreadystatechange = Prototype.emptyFunction;
344344
}
345345
},
346346

347347
isSameOrigin: function(){
348348
var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
349-
return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
349+
return !m || (m[0] === '#{protocol}//#{domain}#{port}'.interpolate({
350350
protocol: location.protocol,
351351
domain : document.domain,
352352
port : location.port ? ':' + location.port : '',

src/prototype/ajax/response.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ Ajax.Response = Class.create({
6868
var transport = this.transport = request.transport,
6969
readyState = this.readyState = transport.readyState;
7070

71-
if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4){
71+
if((readyState > 2 && !Prototype.Browser.IE) || readyState === 4){
7272
this.status = this.getStatus();
7373
this.statusText = this.getStatusText();
7474
this.responseText = String.interpret(transport.responseText);
7575
this.headerJSON = this._getHeaderJSON();
7676
}
7777

78-
if(readyState == 4){
78+
if(readyState === 4){
7979
var xml = transport.responseXML;
8080
this.responseXML = Object.isUndefined(xml) ? null : xml;
8181
this.responseJSON = this._getResponseJSON();
@@ -188,7 +188,7 @@ Ajax.Response = Class.create({
188188

189189
_getResponseJSON: function(){
190190
var options = this.request.options;
191-
if(!options.evalJSON || (options.evalJSON != 'force' &&
191+
if(!options.evalJSON || (options.evalJSON !== 'force' &&
192192
!(this.getHeader('Content-type') || '').include('application/json')) ||
193193
this.responseText.blank()){
194194
return null;

src/prototype/ajax/updater.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ Ajax.Updater = Class.create(Ajax.Request, {
116116
if(!options.evalScripts){
117117
responseText = responseText.stripScripts();
118118
}
119-
120-
if(receiver = $(receiver)){
119+
receiver = $(receiver);
120+
if(receiver){
121121
if(options.insertion){
122122
if(Object.isString(options.insertion)){
123123
var insertion = {};

src/prototype/deprecated.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ var Position = {
8282
if(!mode){
8383
return 0;
8484
}
85-
if(mode == 'vertical'){
85+
if(mode === 'vertical'){
8686
return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
8787
element.offsetHeight;
8888
}
89-
if(mode == 'horizontal'){
89+
if(mode === 'horizontal'){
9090
return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
9191
element.offsetWidth;
9292
}

src/prototype/dom/dom.js

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@
478478
var el = document.createElement('table');
479479
if(el && el.tBodies){
480480
el.innerHTML = '<tbody><tr><td>test</td></tr></tbody>';
481-
var isBuggy = typeof el.tBodies[0] == 'undefined';
481+
var isBuggy = typeof el.tBodies[0] === 'undefined';
482482
el = null;
483483
return isBuggy;
484484
}
@@ -586,8 +586,8 @@
586586
// Purge the element's existing contents of all storage keys and
587587
// event listeners, since said content will be replaced no matter
588588
// what.
589-
var descendants = element.getElementsByTagName('*'),
590-
i = descendants.length;
589+
var descendants = element.getElementsByTagName('*');
590+
var i = descendants.length;
591591
while(i--){
592592
purgeElement(descendants[i]);
593593
}
@@ -610,8 +610,8 @@
610610
}
611611

612612
var nodes = getContentFromAnonymousElement(tagName, content.stripScripts());
613-
for(var i = 0, node; node = nodes[i]; i++){
614-
element.appendChild(node);
613+
for(i = 0; nodes[i]; i++){
614+
element.appendChild(nodes[i]);
615615
}
616616

617617
}
@@ -790,6 +790,7 @@
790790
}
791791

792792
if('outerHTML' in document.documentElement){
793+
// eslint-disable-next-line no-func-assign
793794
replace = replace_IE;
794795
}
795796

@@ -836,8 +837,8 @@
836837
childNodes.reverse();
837838
}
838839

839-
for(var i = 0, node; node = childNodes[i]; i++){
840-
method(element, node);
840+
for(var i = 0; childNodes[i]; i++){
841+
method(element, childNodes[i]);
841842
}
842843

843844
content.evalScripts.bind(content).defer();
@@ -912,7 +913,7 @@
912913
* Wraps an element inside another, then returns the wrapper.
913914
*
914915
* If the given element exists on the page, [[Element.wrap]] will wrap it in
915-
* place — its position will remain the same.
916+
* place — its position will remain the same.
916917
*
917918
* The `wrapper` argument can be _either_ an existing [[Element]] _or_ a
918919
* string representing the tag name of an element to be created. The optional
@@ -1232,7 +1233,7 @@
12321233
element = $(element);
12331234
maximumLength = maximumLength || -1;
12341235
var elements = [];
1235-
1236+
// eslint-disable-next-line no-cond-assign
12361237
while(element = element[property]){
12371238
if(element.nodeType === Node.ELEMENT_NODE){
12381239
elements.push(element);
@@ -1517,17 +1518,23 @@
15171518
// `recursivelyCollect`, except it stops at the first match and doesn't
15181519
// extend any elements except for the returned element.
15191520
function _recursivelyFind(element, property, expression, index){
1520-
element = $(element), expression = expression || 0, index = index || 0;
1521+
element = $(element);
1522+
expression = expression || 0;
1523+
index = index || 0;
1524+
15211525
if(Object.isNumber(expression)){
1522-
index = expression, expression = null;
1526+
index = expression;
1527+
expression = null;
15231528
}
15241529

1530+
// eslint-disable-next-line no-cond-assign
15251531
while(element = element[property]){
15261532
// Skip any non-element nodes.
15271533
if(element.nodeType !== 1){
15281534
continue;
15291535
}
15301536
// Skip any nodes that don't match the expression, if there is one.
1537+
// noinspection JSVoidFunctionReturnValueUsed
15311538
if(expression && !Prototype.Selector.match(element, expression)){
15321539
continue;
15331540
}
@@ -2061,9 +2068,10 @@
20612068
element = $(element);
20622069
var expressions = SLICE.call(arguments, 1).join(', ');
20632070
var siblings = Element.siblings(element), results = [];
2064-
for(var i = 0, sibling; sibling = siblings[i]; i++){
2065-
if(Prototype.Selector.match(sibling, expressions)){
2066-
results.push(sibling);
2071+
for(var i = 0; siblings[i]; i++){
2072+
// noinspection JSVoidFunctionReturnValueUsed
2073+
if(Prototype.Selector.match(siblings[i], expressions)){
2074+
results.push(siblings[i]);
20672075
}
20682076
}
20692077

@@ -2567,7 +2575,8 @@
25672575
var CAMEL_CASED_ATTRIBUTE_NAMES = $w('colSpan rowSpan vAlign dateTime ' +
25682576
'accessKey tabIndex encType maxLength readOnly longDesc frameBorder');
25692577

2570-
for(var i = 0, attr; attr = CAMEL_CASED_ATTRIBUTE_NAMES[i]; i++){
2578+
for(var i = 0; CAMEL_CASED_ATTRIBUTE_NAMES[i]; i++){
2579+
var attr = CAMEL_CASED_ATTRIBUTE_NAMES[i];
25712580
ATTRIBUTE_TRANSLATIONS.write.names[attr.toLowerCase()] = attr;
25722581
ATTRIBUTE_TRANSLATIONS.has.names[attr.toLowerCase()] = attr;
25732582
}
@@ -2784,6 +2793,7 @@
27842793
**/
27852794
function setOpacity(element, value){
27862795
element = $(element);
2796+
// eslint-disable-next-line eqeqeq
27872797
if(value == 1 || value === ''){
27882798
value = '';
27892799
}
@@ -3125,8 +3135,8 @@
31253135
}
31263136
else{
31273137
if(Object.isArray(tagName)){
3128-
for(var i = 0, tag; tag = tagName[i]; i++){
3129-
addMethodsToTagName(tag, methods);
3138+
for(var i = 0; tagName[i]; i++){
3139+
addMethodsToTagName(tagName[i], methods);
31303140
}
31313141
}
31323142
else{
@@ -3167,11 +3177,11 @@
31673177
Object.extend(Form, Form.Methods);
31683178
Object.extend(Form.Element, Form.Element.Methods);
31693179
Object.extend(Element.Methods.ByTag, {
3170-
"FORM" : Object.clone(Form.Methods),
3171-
"INPUT" : Object.clone(Form.Element.Methods),
3172-
"SELECT" : Object.clone(Form.Element.Methods),
3173-
"TEXTAREA": Object.clone(Form.Element.Methods),
3174-
"BUTTON" : Object.clone(Form.Element.Methods)
3180+
'FORM' : Object.clone(Form.Methods),
3181+
'INPUT' : Object.clone(Form.Element.Methods),
3182+
'SELECT' : Object.clone(Form.Element.Methods),
3183+
'TEXTAREA': Object.clone(Form.Element.Methods),
3184+
'BUTTON' : Object.clone(Form.Element.Methods)
31753185
});
31763186
}
31773187

src/prototype/dom/event.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188

189189
// Fix a Safari bug where a text node gets passed as the target of an
190190
// anchor click rather than the anchor itself.
191-
return node.nodeType == Node.TEXT_NODE ? node.parentNode : node;
191+
return node.nodeType === Node.TEXT_NODE ? node.parentNode : node;
192192
}
193193

194194
/**
@@ -385,6 +385,7 @@
385385
}
386386

387387
if(MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED){
388+
// eslint-disable-next-line no-func-assign
388389
getDOMEventName = Prototype.K;
389390
}
390391

0 commit comments

Comments
 (0)