From 8f46a3c9ac075c6300e974efaecd0d10d986a515 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 12 Oct 2011 00:10:20 -0700 Subject: fix(jqLite): attr for boolean attribute should lowercase value --- test/jqLiteSpec.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'test/jqLiteSpec.js') diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 96712210..2f9a5fb9 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -15,7 +15,7 @@ describe('jqLite', function() { this.addMatchers({ toJqEqual: function(expected) { var msg = "Unequal length"; - this.message = function() { return msg; }; + this.message = function() {return msg;}; var value = this.actual && expected && this.actual.length == expected.length; for (var i = 0; value && i < expected.length; i++) { @@ -191,13 +191,16 @@ describe('jqLite', function() { expect(jqLite(b).attr('prop')).toBeFalsy(); }); - it('should read special attributes as strings', function() { + it('should read boolean attributes as strings', function() { var select = jqLite('').attr('multiple')).toBe('multiple'); expect(jqLite('').attr('multiple')).toBe('multiple'); + }); + it('should add/remove boolean attributes', function() { + var select = jqLite(''); + expect(input.attr('readonly')).toBe('readonly'); + expect(input.attr('readOnly')).toBe('readonly'); + expect(input.attr('READONLY')).toBe('readonly'); + + input.attr('readonly', false); + + // attr('readonly') fails in jQuery 1.6.4, so we have to bypass it + //expect(input.attr('readOnly')).toBeUndefined(); + //expect(input.attr('readonly')).toBeUndefined(); + if (msie < 9) { + expect(input[0].getAttribute('readonly')).toBe(''); + } else { + expect(input[0].getAttribute('readonly')).toBe(null); + } + //expect('readOnly' in input[0].attributes).toBe(false); + + input.attr('readOnly', 'READonly'); + expect(input.attr('readonly')).toBe('readonly'); + expect(input.attr('readOnly')).toBe('readonly'); + }); + it('should return undefined for non-existing attributes', function() { var elm = jqLite('
a
'); expect(elm.attr('non-existing')).toBeUndefined(); -- cgit v1.2.3