Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Fixes issue #59 #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
dist
.temp
report
libs
16 changes: 6 additions & 10 deletions src/jquery.addressfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions test/addressfield-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down