Skip to content

Commit

Permalink
fix(util): use querySelector for ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S committed Aug 12, 2018
1 parent 6b92321 commit eab9da5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
13 changes: 13 additions & 0 deletions js/tests/unit/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit eab9da5

Please sign in to comment.