Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

  1. Spaces, e.g. #my-id div
  2. Combinators like + and >, e.g. #my-id>div, #my-id+div, etc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're totally right @glebm I'll fix that asap thanks

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