diff --git a/django/contrib/admin/static/admin/js/SelectBox.js b/django/contrib/admin/static/admin/js/SelectBox.js index 1927b4cefa..e166cf02fc 100644 --- a/django/contrib/admin/static/admin/js/SelectBox.js +++ b/django/contrib/admin/static/admin/js/SelectBox.js @@ -31,7 +31,7 @@ node.displayed = 1; const node_text = node.text.toLowerCase(); for (const token of tokens) { - if (node_text.indexOf(token) === -1) { + if (!node_text.includes(token)) { node.displayed = 0; break; // Once the first token isn't found we're done } diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js index 8c95df7c12..670d13b226 100644 --- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js +++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js @@ -9,10 +9,10 @@ const name = triggeringLink.id.replace(name_regexp, ''); let href = triggeringLink.href; if (add_popup) { - if (href.indexOf('?') === -1) { - href += '?_popup=1'; - } else { + if (href.includes('?')) { href += '&_popup=1'; + } else { + href += '?_popup=1'; } } const win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes'); diff --git a/django/contrib/admin/static/admin/js/cancel.js b/django/contrib/admin/static/admin/js/cancel.js index cfe06c279f..68c2d6662f 100644 --- a/django/contrib/admin/static/admin/js/cancel.js +++ b/django/contrib/admin/static/admin/js/cancel.js @@ -14,10 +14,10 @@ ready(function() { function handleClick(event) { event.preventDefault(); - if (window.location.search.indexOf('&_popup=1') === -1) { - window.history.back(); // Go back if not a popup. + if (window.location.search.includes('&_popup=1')) { + window.close(); // Close the popup. } else { - window.close(); // Otherwise, close the popup. + window.history.back(); // Otherwise, go back. } } diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js index 089ffd38d2..8c1d7feede 100644 --- a/django/contrib/gis/static/gis/js/OLMapWidget.js +++ b/django/contrib/gis/static/gis/js/OLMapWidget.js @@ -50,7 +50,7 @@ ol.inherits(GeometryTypeControl, ol.control.Control); default_lat: 0, default_lon: 0, default_zoom: 12, - is_collection: options.geom_name.indexOf('Multi') > -1 || options.geom_name.indexOf('Collection') > -1 + is_collection: options.geom_name.includes('Multi') || options.geom_name.includes('Collection') }; // Altering using user-provided options diff --git a/django/views/i18n.py b/django/views/i18n.py index b9aa4ac1d4..c4be394900 100644 --- a/django/views/i18n.py +++ b/django/views/i18n.py @@ -137,7 +137,7 @@ js_catalog_template = r""" django.pgettext = function(context, msgid) { var value = django.gettext(context + '\x04' + msgid); - if (value.indexOf('\x04') != -1) { + if (value.includes('\x04')) { value = msgid; } return value; @@ -145,7 +145,7 @@ js_catalog_template = r""" django.npgettext = function(context, singular, plural, count) { var value = django.ngettext(context + '\x04' + singular, context + '\x04' + plural, count); - if (value.indexOf('\x04') != -1) { + if (value.includes('\x04')) { value = django.ngettext(singular, plural, count); } return value;