mirror of https://github.com/twbs/bootstrap.git
fix(util): use querySelector for ids
This commit is contained in:
parent
6b92321f6a
commit
eab9da5beb
|
@ -84,7 +84,7 @@ const Util = (($) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validSelector = selector
|
const validSelector = selector
|
||||||
if (selector.charAt(0) === '#') {
|
if (selector.charAt(0) === '#' && selector.indexOf(',') === -1) {
|
||||||
selector = selector.substr(1)
|
selector = selector.substr(1)
|
||||||
method = 'getElementById'
|
method = 'getElementById'
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,19 @@ $(function () {
|
||||||
assert.ok(spy.called)
|
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) {
|
QUnit.test('Util.typeCheckConfig should thrown an error when a bad config is passed', function (assert) {
|
||||||
assert.expect(1)
|
assert.expect(1)
|
||||||
var namePlugin = 'collapse'
|
var namePlugin = 'collapse'
|
||||||
|
|
Loading…
Reference in New Issue