diff options
| author | Johann-S <[email protected]> | 2018-08-11 22:40:47 +0200 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2018-08-12 17:01:01 +0200 |
| commit | eab9da5beb5a2fdba8be4e54dfcdac0de4eba2f6 (patch) | |
| tree | 3902027fb0c53a081cbbb52072aee0a4b51a4f00 | |
| parent | 6b92321f6a04f07e0a3531d0e546c3cc20867bdb (diff) | |
| download | bootstrap-eab9da5beb5a2fdba8be4e54dfcdac0de4eba2f6.tar.xz bootstrap-eab9da5beb5a2fdba8be4e54dfcdac0de4eba2f6.zip | |
fix(util): use querySelector for ids
| -rw-r--r-- | js/src/util.js | 2 | ||||
| -rw-r--r-- | js/tests/unit/util.js | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/js/src/util.js b/js/src/util.js index 3008c2278..8165ab46f 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -84,7 +84,7 @@ const Util = (($) => { } const validSelector = selector - if (selector.charAt(0) === '#') { + if (selector.charAt(0) === '#' && selector.indexOf(',') === -1) { selector = selector.substr(1) method = 'getElementById' } diff --git a/js/tests/unit/util.js b/js/tests/unit/util.js index 49252701a..4f44c2907 100644 --- a/js/tests/unit/util.js +++ b/js/tests/unit/util.js @@ -32,6 +32,19 @@ $(function () { assert.ok(spy.called) }) + QUnit.test('Util.getSelectorFromElement should use querySelector when there are multi ids', function (assert) { + assert.expect(2) + + var spy = sinon.spy(document, 'querySelector') + + var $el = $('<div data-target="#j7, #j8"></div>').appendTo($('#qunit-fixture')) + $('<div id="j7" />').appendTo($('#qunit-fixture')) + $('<div id="j8" />').appendTo($('#qunit-fixture')) + + assert.strictEqual(Util.getSelectorFromElement($el[0]), '#j7, #j8') + assert.ok(spy.called) + }) + QUnit.test('Util.typeCheckConfig should thrown an error when a bad config is passed', function (assert) { assert.expect(1) var namePlugin = 'collapse' |
