From: Johann-S Date: Thu, 8 Nov 2018 12:43:23 +0000 (+0100) Subject: Improve manipulator coverage X-Git-Tag: v5.0.0-alpha1~1284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57d50b2134077f3ef93757b52ddf51a86632e92c;p=thirdparty%2Fbootstrap.git Improve manipulator coverage --- diff --git a/js/src/dom/manipulator.js b/js/src/dom/manipulator.js index b9135aa791..d100a98736 100644 --- a/js/src/dom/manipulator.js +++ b/js/src/dom/manipulator.js @@ -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 }, diff --git a/js/tests/unit/dom/manipulator.js b/js/tests/unit/dom/manipulator.js index 8a0be08ea7..4b20529d41 100644 --- a/js/tests/unit/dom/manipulator.js +++ b/js/tests/unit/dom/manipulator.js @@ -41,16 +41,19 @@ $(function () { }) QUnit.test('should get data attributes', function (assert) { - assert.expect(2) + assert.expect(4) var $div = $('
').appendTo('#qunit-fixture') var $div2 = $('
').appendTo('#qunit-fixture') + var $div3 = $('
').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() })