diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js index 9541da13d1..aa49254257 100644 --- a/django/contrib/admin/static/admin/js/SelectFilter2.js +++ b/django/contrib/admin/static/admin/js/SelectFilter2.js @@ -26,10 +26,10 @@ Requires jQuery, core.js, and SelectBox.js. var ps = from_box.parentNode.getElementsByTagName('p'); for (var i = 0; i < ps.length; i++) { - if (ps[i].className.indexOf("info") !== -1) { + if (ps[i].classList.contains("info")) { // Remove
, because it just gets in the way. from_box.parentNode.removeChild(ps[i]); - } else if (ps[i].className.indexOf("help") !== -1) { + } else if (ps[i].classList.contains("help")) { // Move help text up to the top so it isn't below the select // boxes or wrapped off on the side to the right of the add // button: @@ -112,7 +112,7 @@ Requires jQuery, core.js, and SelectBox.js. // Set up the JavaScript event handlers for the select box filter interface var move_selection = function(e, elem, move_func, from, to) { - if (elem.className.indexOf('active') !== -1) { + if (elem.classList.contains('active')) { move_func(from, to); SelectFilter.refresh_icons(field_id); } diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index a2ef721ee5..f04dbc51bf 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -38,11 +38,11 @@ var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { var inp = inputs[i]; - if (inp.type === 'text' && inp.className.match(/vTimeField/)) { + if (inp.type === 'text' && inp.classList.contains('vTimeField')) { DateTimeShortcuts.addClock(inp); DateTimeShortcuts.addTimezoneWarning(inp); } - else if (inp.type === 'text' && inp.className.match(/vDateField/)) { + else if (inp.type === 'text' && inp.classList.contains('vDateField')) { DateTimeShortcuts.addCalendar(inp); DateTimeShortcuts.addTimezoneWarning(inp); } diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js index f4c57c40e5..4f507be4b2 100644 --- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js +++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js @@ -44,7 +44,7 @@ function dismissRelatedLookupPopup(win, chosenId) { var name = windowname_to_id(win.name); var elem = document.getElementById(name); - if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) { + if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { elem.value += ',' + chosenId; } else { document.getElementById(name).value = chosenId; @@ -81,7 +81,7 @@ if (elemName === 'SELECT') { elem.options[elem.options.length] = new Option(newRepr, newId, true, true); } else if (elemName === 'INPUT') { - if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) { + if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { elem.value += ',' + newId; } else { elem.value = newId; diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js index 0aca1c9d88..a50aa999e6 100644 --- a/django/contrib/gis/static/gis/js/OLMapWidget.js +++ b/django/contrib/gis/static/gis/js/OLMapWidget.js @@ -8,7 +8,7 @@ var GeometryTypeControl = function(opt_options) { var element = document.createElement('div'); element.className = 'switch-type type-' + options.type + ' ol-control ol-unselectable'; if (options.active) { - element.className += " type-active"; + element.classList.add("type-active"); } var self = this; @@ -21,10 +21,9 @@ var GeometryTypeControl = function(opt_options) { type: options.type }); options.widget.map.addInteraction(options.widget.interactions.draw); - var className = options.widget.currentGeometryType.element.className.replace(/ type-active/g, ''); - options.widget.currentGeometryType.element.className = className; + options.widget.currentGeometryType.element.classList.remove('type-active'); options.widget.currentGeometryType = self; - element.className += " type-active"; + element.classList.add("type-active"); } };