From 0aa6fe79719103c0b35e913f59a135986722986a Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Fri, 26 Jul 2019 05:50:19 -0400 Subject: [PATCH] Select2 now clears the internal ID when it is destroyed This fixes a bug where if you cloned a Select2, the internal ID used for mapping elements (specifically the `'); + + Utils.RemoveData($element[0]); + + assert.notEqual( + $element.attr('data-select2-id'), + 'test', + 'The internal attribute was not removed when the data was cleared' + ); +}); + +test('The internal cache for the element is cleared', function (assert) { + var $element = $(''); + + Utils.__cache.test = { + 'foo': 'bar' + }; + + Utils.RemoveData($element[0]); + + assert.equal(Utils.__cache.test, null, 'The cache should now be empty'); +}); + +test('Calling it on an element without data works', function (assert) { + assert.expect(0); + + var $element = $(''); + + Utils.RemoveData($element[0]); +}); \ No newline at end of file