Ticket #36284: patch.txt

File patch.txt, 2.4 KB (added by Matthias Kestenholz, 13 days ago)
Line 
1diff --git i/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js w/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
2index 5395386087..5ea8ff4017 100644
3--- i/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
4+++ w/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
5@@ -58,9 +58,9 @@
6 elem.value = chosenId;
7 }
8 $(elem).trigger('change');
9- const index = window.relatedWindows.indexOf(win);
10+ const index = relatedWindows.indexOf(win);
11 if (index > -1) {
12- window.relatedWindows.splice(index, 1);
13+ relatedWindows.splice(index, 1);
14 }
15 win.close();
16 }
17@@ -211,6 +211,8 @@
18 window.showAddAnotherPopup = showRelatedObjectPopup;
19 window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
20
21+ window.__SECRET_INTERNALS_relatedWindows = relatedWindows;
22+
23 window.addEventListener('unload', function(evt) {
24 window.dismissChildPopups();
25 });
26diff --git i/js_tests/admin/RelatedObjectLookups.test.js w/js_tests/admin/RelatedObjectLookups.test.js
27index 722aa7ae7b..3d28e16163 100644
28--- i/js_tests/admin/RelatedObjectLookups.test.js
29+++ w/js_tests/admin/RelatedObjectLookups.test.js
30@@ -8,7 +8,6 @@ QUnit.module('admin.RelatedObjectLookups', {
31 <input type="text" id="test_id" name="test" />
32 <input type="text" id="many_test_id" name="many_test" class="vManyToManyRawIdAdminField" />
33 `);
34- window.relatedWindows = window.relatedWindows || [];
35 }
36 });
37
38@@ -31,10 +30,10 @@ QUnit.test('dismissRelatedLookupPopup removes window from relatedWindows array',
39 name: testId,
40 close: function() {}
41 };
42- window.relatedWindows.push(mockWin);
43- assert.equal(window.relatedWindows.indexOf(mockWin), 0, 'Window should be in relatedWindows array');
44+ window.__SECRET_INTERNALS_relatedWindows.push(mockWin);
45+ assert.equal(window.__SECRET_INTERNALS_relatedWindows.indexOf(mockWin), 0, 'Window should be in relatedWindows array');
46 window.dismissRelatedLookupPopup(mockWin, '123');
47- assert.equal(window.relatedWindows.indexOf(mockWin), -1, 'Window should be removed from relatedWindows array');
48+ assert.equal(window.__SECRET_INTERNALS_relatedWindows.indexOf(mockWin), -1, 'Window should be removed from relatedWindows array');
49 });
50
51 QUnit.test('dismissRelatedLookupPopup triggers change event for single value field', function(assert) {
Back to Top