From 1cc0e4173de01d6c4103910d231a24b2834f4d91 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 19 Mar 2012 12:20:57 -0700 Subject: bug(ie7): incorrectly set all inputs to disabled In ie7 all of the input fields are set to readonly and disabled, because ie7 enumerates over all attributes even if the are not declared on the element. --- test/directive/inputSpec.js | 23 +++++++++++++++++++++++ test/jqLiteSpec.js | 7 +++++++ 2 files changed, 30 insertions(+) (limited to 'test') diff --git a/test/directive/inputSpec.js b/test/directive/inputSpec.js index 2a7244c9..22c77f53 100644 --- a/test/directive/inputSpec.js +++ b/test/directive/inputSpec.js @@ -316,6 +316,29 @@ describe('input', function() { }); + it('should not set readonly or disabled property on ie7', function() { + this.addMatchers({ + toBeOff: function(attributeName) { + var actualValue = this.actual.attr(attributeName); + this.message = function() { + return "Attribute '" + attributeName + "' expected to be off but was '" + actualValue + + "' in: " + angular.mock.dump(this.actual); + } + + return !actualValue || actualValue == 'false'; + } + }); + + compileInput(''); + expect(inputElm.prop('readOnly')).toBe(false); + expect(inputElm.prop('disabled')).toBe(false); + + expect(inputElm).toBeOff('readOnly'); + expect(inputElm).toBeOff('readonly'); + expect(inputElm).toBeOff('disabled'); + }); + + it('should cleanup it self from the parent form', function() { compileInput(''); diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 417b912c..fbe6edcb 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -268,6 +268,13 @@ describe('jqLite', function() { var elm = jqLite('
a
'); expect(elm.attr('non-existing')).toBeUndefined(); }); + + it('should return undefined for non-existing attributes on input', function() { + var elm = jqLite(''); + expect(elm.attr('readonly')).toBeUndefined(); + expect(elm.attr('readOnly')).toBeUndefined(); + expect(elm.attr('disabled')).toBeUndefined(); + }); }); -- cgit v1.2.3