From 4d75d27fbc62023a7778957ec24a517d9f259804 Mon Sep 17 00:00:00 2001 From: Francois Zaninotto Date: Thu, 6 Aug 2015 18:02:27 +0200 Subject: [PATCH 1/2] Fix custom attributes on fields Fixes #497 --- src/javascripts/ng-admin/Crud/field/maButtonField.js | 2 +- src/javascripts/ng-admin/Crud/field/maCheckboxField.js | 2 +- src/javascripts/ng-admin/Crud/field/maFileField.js | 2 +- src/javascripts/ng-admin/Crud/field/maInputField.js | 2 +- src/javascripts/ng-admin/Crud/field/maJsonField.js | 2 +- src/javascripts/ng-admin/Crud/field/maTextField.js | 2 +- src/javascripts/test/unit/Crud/field/maInputFieldSpec.js | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/javascripts/ng-admin/Crud/field/maButtonField.js b/src/javascripts/ng-admin/Crud/field/maButtonField.js index 045ec3e3..c47a62f4 100644 --- a/src/javascripts/ng-admin/Crud/field/maButtonField.js +++ b/src/javascripts/ng-admin/Crud/field/maButtonField.js @@ -23,7 +23,7 @@ define(function () { var a = element.children()[0]; var attributes = field.attributes(); for (var name in attributes) { - a[name] = attributes[name]; + a.setAttribute(name, attributes[name]); } scope.toggle = function() { this.value = !this.value; diff --git a/src/javascripts/ng-admin/Crud/field/maCheckboxField.js b/src/javascripts/ng-admin/Crud/field/maCheckboxField.js index 0de038f9..25838865 100644 --- a/src/javascripts/ng-admin/Crud/field/maCheckboxField.js +++ b/src/javascripts/ng-admin/Crud/field/maCheckboxField.js @@ -23,7 +23,7 @@ define(function (require) { var input = element.children()[0]; var attributes = field.attributes(); for (var name in attributes) { - input[name] = attributes[name]; + input.setAttribute(name, attributes[name]); } }, template: diff --git a/src/javascripts/ng-admin/Crud/field/maFileField.js b/src/javascripts/ng-admin/Crud/field/maFileField.js index 2eb7afa2..44d5a791 100644 --- a/src/javascripts/ng-admin/Crud/field/maFileField.js +++ b/src/javascripts/ng-admin/Crud/field/maFileField.js @@ -48,7 +48,7 @@ define(function (require) { var input = element.find('input')[0]; var attributes = field.attributes(); for (var name in attributes) { - input[name] = attributes[name]; + input.setAttribute(name, attributes[name]); } scope.fileSelected = function(selectedFiles) { diff --git a/src/javascripts/ng-admin/Crud/field/maInputField.js b/src/javascripts/ng-admin/Crud/field/maInputField.js index d63661f5..27fa77f2 100644 --- a/src/javascripts/ng-admin/Crud/field/maInputField.js +++ b/src/javascripts/ng-admin/Crud/field/maInputField.js @@ -29,7 +29,7 @@ define(function (require) { continue; } - input[name] = attributes[name]; + input.setAttribute(name, attributes[name]); } }, template: diff --git a/src/javascripts/ng-admin/Crud/field/maJsonField.js b/src/javascripts/ng-admin/Crud/field/maJsonField.js index 477f664b..ef95bb2d 100644 --- a/src/javascripts/ng-admin/Crud/field/maJsonField.js +++ b/src/javascripts/ng-admin/Crud/field/maJsonField.js @@ -40,7 +40,7 @@ function maJsonField() { var input = element.children()[0]; var attributes = field.attributes(); for (var name in attributes) { - input[name] = attributes[name]; + input.setAttribute(name, attributes[name]); } scope.$watch('jsonValue', function(jsonValue) { if (jsonValue == '' || typeof jsonValue === 'undefined') { diff --git a/src/javascripts/ng-admin/Crud/field/maTextField.js b/src/javascripts/ng-admin/Crud/field/maTextField.js index 43a462c1..71c68774 100644 --- a/src/javascripts/ng-admin/Crud/field/maTextField.js +++ b/src/javascripts/ng-admin/Crud/field/maTextField.js @@ -22,7 +22,7 @@ define(function (require) { var input = element.children()[0]; var attributes = field.attributes(); for (var name in attributes) { - input[name] = attributes[name]; + input.setAttribute(name, attributes[name]); } }, template: diff --git a/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js b/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js index 45fa3e1a..15981ae9 100644 --- a/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js +++ b/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js @@ -45,8 +45,8 @@ describe('directive: input-field', function () { var element = $compile(directiveUsage)(scope); scope.$digest(); var input = element.children()[0]; - expect(input.min).toEqual('-2'); - expect(input.max).toEqual('2'); + expect(input.getAttribute('min')).toEqual('-2'); + expect(input.getAttribute('max')).toEqual('2'); }); it("should contain the bounded value", function () { From 83fdf561643cc99ad6f56218e22b2459fae77545 Mon Sep 17 00:00:00 2001 From: Francois Zaninotto Date: Thu, 6 Aug 2015 18:38:26 +0200 Subject: [PATCH 2/2] Fix tests --- src/javascripts/test/unit/Crud/field/maInputFieldSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js b/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js index 15981ae9..0454c8c2 100644 --- a/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js +++ b/src/javascripts/test/unit/Crud/field/maInputFieldSpec.js @@ -37,7 +37,7 @@ describe('directive: input-field', function () { scope.field = new Field().attributes({ autocomplete: 'off' }); var element = $compile(directiveUsage)(scope); scope.$digest(); - expect(element.children()[0].autocomplete).toEqual('off'); + expect(element.children()[0].getAttribute('autocomplete')).toEqual('off'); }); it("should use the field min and max attributes", function () {