0
0
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:
Johann-S 2018-11-08 13:43:23 +01:00 committed by XhmikosR
parent 6cfc78f2d9
commit 57d50b2134
2 changed files with 10 additions and 8 deletions

View File

@ -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
},

View File

@ -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()
})