Skip to content

Commit 5fd270c

Browse files
author
Nadim Afana
committed
Added an integration test to ensure issue does not come back in the future.
1 parent fba261c commit 5fd270c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tests/integration/jquery-calls.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,32 @@ test('multiple elements with arguments works', function (assert) {
2525
'2',
2626
'The call should also change the value on the second element'
2727
);
28+
});
29+
30+
test('initializes correctly when jQuery $.data contains cyclic reference object', function (assert) {
31+
var $ = require('jquery');
32+
require('jquery.select2');
33+
34+
var $select = $(
35+
'<select>' +
36+
'<option>One</option>' +
37+
'<option>Two</option>' +
38+
'<option value="3" selected>Three</option>' +
39+
'</select>'
40+
);
41+
42+
// Add a circular reference object using jQuery.
43+
var recursiveObject = {};
44+
45+
recursiveObject['same'] = recursiveObject;
46+
47+
$select.data('same', recursiveObject);
48+
49+
$select.select2();
50+
51+
assert.equal(
52+
$select.val(),
53+
'3',
54+
'The option value should be pulled correctly'
55+
);
2856
});

0 commit comments

Comments
 (0)