diff --git a/.gitignore b/.gitignore index f99ddbe..5b6a7a2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ dist .temp report +libs \ No newline at end of file diff --git a/src/jquery.addressfield.js b/src/jquery.addressfield.js index 4f56ef1..fd5c38e 100644 --- a/src/jquery.addressfield.js +++ b/src/jquery.addressfield.js @@ -454,18 +454,14 @@ * Copies select HTML attributes from a given element to the supplied element. */ $.fn.addressfield.copyAttrsTo = function($to) { - var attributes = ['class', 'id', 'name', 'propdescname'], - $this = $(this); + var $this = $(this); $.each($this[0].attributes, function () { - if ($.inArray(this.name, attributes) !== -1) { - // Compatibility for IE8. - if (this.name === 'propdescname') { - $to.attr('name', this.value); - } - else { - $to.attr(this.name, this.value); - } + // Compatibility for IE8. + if (this.name === 'propdescname') { + $to.attr('name', this.value); + } else { + $to.attr(this.name, this.value); } }); }; diff --git a/test/addressfield-test.js b/test/addressfield-test.js index 830c596..b907951 100644 --- a/test/addressfield-test.js +++ b/test/addressfield-test.js @@ -505,11 +505,11 @@ $.fn.addressfield.copyAttrsTo.call($mock, $target); // Ensure expected behavior. - strictEqual(mockAttrData.length, 2, 'called exactly 3 times'); + strictEqual(mockAttrData.length, 3, 'called exactly 3 times'); ok($.inArray('id', mockAttrData) > -1, 'id copied'); ok($.inArray('name', mockAttrData) > -1, 'name copied'); strictEqual($.inArray('class', mockAttrData), -1, 'class not copied'); - strictEqual($.inArray('other', mockAttrData), -1, 'class not copied'); + ok($.inArray('other', mockAttrData) > -1, 'other copied'); // Fake IE8 test: add a propdescname attribute to the DOM element. mockAttrData = [];