diff options
| author | Igor Minar | 2011-10-12 00:10:20 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-10-12 23:04:47 -0700 | 
| commit | 8f46a3c9ac075c6300e974efaecd0d10d986a515 (patch) | |
| tree | 49490d3d3c66cb345c9e0ade7f01e60a275c7b5b /test/jqLiteSpec.js | |
| parent | 66fdb36ecbe0ec58ba3367a585b506e11ca1c8ad (diff) | |
| download | angular.js-8f46a3c9ac075c6300e974efaecd0d10d986a515.tar.bz2 | |
fix(jqLite): attr for boolean attribute should lowercase value
Diffstat (limited to 'test/jqLiteSpec.js')
| -rw-r--r-- | test/jqLiteSpec.js | 30 | 
1 files changed, 28 insertions, 2 deletions
| 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('<select>');        expect(select.attr('multiple')).toBeUndefined();        expect(jqLite('<select multiple>').attr('multiple')).toBe('multiple');        expect(jqLite('<select multiple="">').attr('multiple')).toBe('multiple');        expect(jqLite('<select multiple="x">').attr('multiple')).toBe('multiple'); +    }); +    it('should add/remove boolean attributes', function() { +      var select = jqLite('<select>');        select.attr('multiple', false);        expect(select.attr('multiple')).toBeUndefined(); @@ -205,6 +208,29 @@ describe('jqLite', function() {        expect(select.attr('multiple')).toBe('multiple');      }); +    it('should normalize the case of boolean attributes', function() { +      var input = jqLite('<input readonly>'); +      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('<div class="any">a</div>');        expect(elm.attr('non-existing')).toBeUndefined(); | 
