mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
Improve manipulator coverage
This commit is contained in:
parent
6cfc78f2d9
commit
57d50b2134
@ -63,13 +63,10 @@ const Manipulator = {
|
||||
}
|
||||
}
|
||||
|
||||
for (const key in attributes) {
|
||||
if (!Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||
continue
|
||||
}
|
||||
|
||||
attributes[key] = normalizeData(attributes[key])
|
||||
}
|
||||
Object.keys(attributes)
|
||||
.forEach((key) => {
|
||||
attributes[key] = normalizeData(attributes[key])
|
||||
})
|
||||
|
||||
return attributes
|
||||
},
|
||||
|
@ -41,16 +41,19 @@ $(function () {
|
||||
})
|
||||
|
||||
QUnit.test('should get data attributes', function (assert) {
|
||||
assert.expect(2)
|
||||
assert.expect(4)
|
||||
|
||||
var $div = $('<div data-test="js" data-test2="js2" />').appendTo('#qunit-fixture')
|
||||
var $div2 = $('<div data-test3="js" data-test4="js2" />').appendTo('#qunit-fixture')
|
||||
var $div3 = $('<div attri="1" />').appendTo('#qunit-fixture')
|
||||
|
||||
assert.propEqual(Manipulator.getDataAttributes($div[0]), {
|
||||
test: 'js',
|
||||
test2: 'js2'
|
||||
})
|
||||
|
||||
assert.propEqual(Manipulator.getDataAttributes(null), {})
|
||||
|
||||
var stub = sinon
|
||||
.stub(Object, 'getOwnPropertyDescriptor')
|
||||
.callsFake(function () {
|
||||
@ -62,6 +65,8 @@ $(function () {
|
||||
test4: 'js2'
|
||||
})
|
||||
|
||||
assert.propEqual(Manipulator.getDataAttributes($div3[0]), {})
|
||||
|
||||
stub.restore()
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user