Skip to content

Commit 33d496b

Browse files
committed
Use strict equality in JS files.
1 parent 9d791da commit 33d496b

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

lib/matplotlib/backends/web_backend/js/mpl.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mpl.figure = function (figure_id, websocket, ondownload, parent_element) {
2222

2323
this.ws = websocket;
2424

25-
this.supports_binary = this.ws.binaryType != undefined;
25+
this.supports_binary = this.ws.binaryType !== undefined;
2626

2727
if (!this.supports_binary) {
2828
var warnings = document.getElementById('mpl-warnings');
@@ -62,14 +62,14 @@ mpl.figure = function (figure_id, websocket, ondownload, parent_element) {
6262
this.ws.onopen = function () {
6363
fig.send_message('supports_binary', { value: fig.supports_binary });
6464
fig.send_message('send_image_mode', {});
65-
if (mpl.ratio != 1) {
65+
if (mpl.ratio !== 1) {
6666
fig.send_message('set_dpi_ratio', { dpi_ratio: mpl.ratio });
6767
}
6868
fig.send_message('refresh', {});
6969
};
7070

7171
this.imageObj.onload = function () {
72-
if (fig.image_mode == 'full') {
72+
if (fig.image_mode === 'full') {
7373
// Full images could contain transparency (where diff images
7474
// almost always do), so we need to clear the canvas so that
7575
// there is no ghosting.
@@ -336,7 +336,7 @@ mpl.figure.prototype.handle_save = function (fig, _msg) {
336336

337337
mpl.figure.prototype.handle_resize = function (fig, msg) {
338338
var size = msg['size'];
339-
if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {
339+
if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {
340340
fig._resize_canvas(size[0], size[1]);
341341
fig.send_message('refresh', {});
342342
}
@@ -434,7 +434,7 @@ mpl.figure.prototype._make_on_message_function = function (fig) {
434434
return;
435435
} else if (
436436
typeof evt.data === 'string' &&
437-
evt.data.slice(0, 21) == 'data:image/png;base64'
437+
evt.data.slice(0, 21) === 'data:image/png;base64'
438438
) {
439439
fig.imageObj.src = evt.data;
440440
fig.updated_canvas_event();
@@ -485,7 +485,7 @@ mpl.findpos = function (e) {
485485
} else if (e.srcElement) {
486486
targ = e.srcElement;
487487
}
488-
if (targ.nodeType == 3) {
488+
if (targ.nodeType === 3) {
489489
// defeat Safari bug
490490
targ = targ.parentNode;
491491
}
@@ -546,25 +546,25 @@ mpl.figure.prototype._key_event_extra = function (_event, _name) {
546546

547547
mpl.figure.prototype.key_event = function (event, name) {
548548
// Prevent repeat events
549-
if (name == 'key_press') {
549+
if (name === 'key_press') {
550550
if (event.which === this._key) {
551551
return;
552552
} else {
553553
this._key = event.which;
554554
}
555555
}
556-
if (name == 'key_release') {
556+
if (name === 'key_release') {
557557
this._key = null;
558558
}
559559

560560
var value = '';
561-
if (event.ctrlKey && event.which != 17) {
561+
if (event.ctrlKey && event.which !== 17) {
562562
value += 'ctrl+';
563563
}
564-
if (event.altKey && event.which != 18) {
564+
if (event.altKey && event.which !== 18) {
565565
value += 'alt+';
566566
}
567-
if (event.shiftKey && event.which != 16) {
567+
if (event.shiftKey && event.which !== 16) {
568568
value += 'shift+';
569569
}
570570

@@ -578,7 +578,7 @@ mpl.figure.prototype.key_event = function (event, name) {
578578
};
579579

580580
mpl.figure.prototype.toolbar_button_onclick = function (name) {
581-
if (name == 'download') {
581+
if (name === 'download') {
582582
this.handle_save(this, null);
583583
} else {
584584
this.send_message('toolbar_button', { name: name });

lib/matplotlib/backends/web_backend/js/nbagg_mpl.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ mpl.figure.prototype._key_event_extra = function (event, _name) {
179179
}
180180

181181
// Check for shift+enter
182-
if (event.shiftKey && event.which == 13) {
182+
if (event.shiftKey && event.which === 13) {
183183
this.canvas_div.blur();
184184
// select the cell after this one
185185
var index = IPython.notebook.find_cell_index(this.cell_info[0]);
@@ -207,7 +207,7 @@ mpl.find_output_cell = function (html_output) {
207207
// IPython >= 3 moved mimebundle to data attribute of output
208208
data = data.data;
209209
}
210-
if (data['text/html'] == html_output) {
210+
if (data['text/html'] === html_output) {
211211
return [cell, data, j];
212212
}
213213
}
@@ -217,7 +217,7 @@ mpl.find_output_cell = function (html_output) {
217217

218218
// Register the function which deals with the matplotlib target/channel.
219219
// The kernel may be null if the page has been refreshed.
220-
if (IPython.notebook.kernel != null) {
220+
if (IPython.notebook.kernel !== null) {
221221
IPython.notebook.kernel.comm_manager.register_target(
222222
'matplotlib',
223223
mpl.mpl_figure_comm

0 commit comments

Comments
 (0)