diff --git a/js/src/tab.js b/js/src/tab.js index af296f74fe21..7333f22a1f86 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -142,7 +142,7 @@ class Tab { _activate(element, container, callback) { let activeElements - if (container.nodeName === 'UL') { + if (container && container.nodeName === 'UL') { activeElements = $(container).find(Selector.ACTIVE_UL) } else { activeElements = $(container).children(Selector.ACTIVE) diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index e28ca83a756e..3ce29b662408 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -414,4 +414,49 @@ $(function () { }) .trigger($.Event('click')) }) + + QUnit.test('should handle removed tabs', function (assert) { + assert.expect(1) + var done = assert.async() + + var html = [ + '
', + '