diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js index 3f012a5b47..1d8f602d40 100644 --- a/django/contrib/admin/static/admin/js/collapse.js +++ b/django/contrib/admin/static/admin/js/collapse.js @@ -1,16 +1,6 @@ /*global gettext*/ (function() { 'use strict'; - var closestElem = function(elem, tagName) { - if (elem.nodeName === tagName.toUpperCase()) { - return elem; - } - if (elem.parentNode.nodeName === 'BODY') { - return null; - } - return elem.parentNode && closestElem(elem.parentNode, tagName); - }; - window.addEventListener('load', function() { // Add anchor tag for Show/Hide link var fieldsets = document.querySelectorAll('fieldset.collapse'); @@ -35,7 +25,7 @@ if (ev.target.matches('.collapse-toggle')) { ev.preventDefault(); ev.stopPropagation(); - var fieldset = closestElem(ev.target, 'fieldset'); + var fieldset = ev.target.closest('fieldset'); if (fieldset.classList.contains('collapsed')) { // Show ev.target.textContent = gettext('Hide'); diff --git a/django/contrib/admin/static/admin/js/collapse.min.js b/django/contrib/admin/static/admin/js/collapse.min.js index 33a93573bd..67b2d21335 100644 --- a/django/contrib/admin/static/admin/js/collapse.min.js +++ b/django/contrib/admin/static/admin/js/collapse.min.js @@ -1,3 +1,2 @@ -(function(){var e=function(b,a){return b.nodeName===a.toUpperCase()?b:"BODY"===b.parentNode.nodeName?null:b.parentNode&&e(b.parentNode,a)};window.addEventListener("load",function(){for(var b=document.querySelectorAll("fieldset.collapse"),a=0;a