Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6555

Show
Ignore:
Timestamp:
04/24/07 02:50:52 (1 year ago)
Author:
sam
Message:

prototype: Add extra spacing so Array#toJSON and Hash#toJSON generate YAML-loadable JSON. Closes #7883.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/trunk/CHANGELOG

    r6536 r6555  
    11*SVN* 
     2 
     3* Add extra spacing so Array#toJSON and Hash#toJSON generate YAML-loadable JSON.  Closes #7883.  [Andrew Dupont] 
    24 
    35* Fix Form.request for forms containing an input element with name="action".  Closes #8063.  [Thomas Fuchs, Mislav Marohnić] 
  • spinoffs/prototype/trunk/src/array.js

    r6381 r6555  
    110110      if (value !== undefined) results.push(value); 
    111111    }); 
    112     return '[' + results.join(',') + ']'; 
     112    return '[' + results.join(', ') + ']'; 
    113113  } 
    114114}); 
  • spinoffs/prototype/trunk/src/base.js

    r6368 r6555  
    4343      var value = Object.toJSON(object[property]); 
    4444      if (value !== undefined) 
    45         results.push(property.toJSON() + ':' + value); 
     45        results.push(property.toJSON() + ': ' + value); 
    4646    } 
    47     return '{' + results.join(',') + '}'; 
     47    return '{' + results.join(', ') + '}'; 
    4848  }, 
    4949   
  • spinoffs/prototype/trunk/src/hash.js

    r6481 r6555  
    2929    this.prototype._each.call(object, function(pair) { 
    3030      var value = Object.toJSON(pair.value); 
    31       if (value !== undefined) results.push(pair.key.toJSON() + ':' + value); 
     31      if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value); 
    3232    }); 
    33     return '{' + results.join(',') + '}'; 
     33    return '{' + results.join(', ') + '}'; 
    3434  } 
    3535}); 
  • spinoffs/prototype/trunk/test/unit/array.html

    r6384 r6555  
    124124      assertEqual('[]', [].toJSON()); 
    125125      assertEqual('[\"a\"]', ['a'].toJSON()); 
    126       assertEqual('[\"a\",1]', ['a', 1].toJSON()); 
    127       assertEqual('[\"a\",{\"b\":null}]', ['a', {'b': null}].toJSON()); 
     126      assertEqual('[\"a\", 1]', ['a', 1].toJSON()); 
     127      assertEqual('[\"a\", {\"b\": null}]', ['a', {'b': null}].toJSON()); 
    128128    }}, 
    129129         
  • spinoffs/prototype/trunk/test/unit/base.html

    r6363 r6555  
    8585      assertEqual('withBindArgsAndArgs,arg1,arg2,arg3,arg4', globalBindTest); 
    8686    }}, 
    87  
     87     
    8888    testObjectInspect: function() { with(this) { 
    8989      assertEqual('undefined', Object.inspect()); 
     
    100100      assertEqual('[]', Object.toJSON([])); 
    101101      assertEqual('[\"a\"]', Object.toJSON(['a'])); 
    102       assertEqual('[\"a\",1]', Object.toJSON(['a', 1])); 
    103       assertEqual('[\"a\",{\"b\":null}]', Object.toJSON(['a', {'b': null}])); 
    104       assertEqual('{\"a\":\"hello!\"}', Object.toJSON({a: 'hello!'})); 
     102      assertEqual('[\"a\", 1]', Object.toJSON(['a', 1])); 
     103      assertEqual('[\"a\", {\"b\": null}]', Object.toJSON(['a', {'b': null}])); 
     104      assertEqual('{\"a\": \"hello!\"}', Object.toJSON({a: 'hello!'})); 
    105105      assertEqual('{}', Object.toJSON({})); 
    106106      assertEqual('{}', Object.toJSON({a: undefined, b: undefined, c: Prototype.K})); 
    107       assertEqual('{\"b\":[false,true],\"c\":{\"a\":\"hello!\"}}', 
     107      assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
    108108        Object.toJSON({'b': [undefined, false, true, undefined], c: {a: 'hello!'}})); 
    109       assertEqual('{\"b\":[false,true],\"c\":{\"a\":\"hello!\"}}', 
     109      assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
    110110        Object.toJSON($H({'b': [undefined, false, true, undefined], c: {a: 'hello!'}}))); 
    111111      assertEqual('true', Object.toJSON(true)); 
     
    149149        document.body.appendChild(div); 
    150150        var tobj = new TestObj(); 
    151         var eventTest = {test:true}; 
     151        var eventTest = { test: true }; 
    152152        var call = tobj.assertingEventHandler.bindAsEventListener(tobj, 
    153           this.assertEqual.bind(this,eventTest), 
    154           this.assertEqual.bind(this,arg1), 
    155           this.assertEqual.bind(this,arg2), 
    156           this.assertEqual.bind(this,arg3), arg1, arg2, arg3 ); 
     153          this.assertEqual.bind(this, eventTest), 
     154          this.assertEqual.bind(this, arg1), 
     155          this.assertEqual.bind(this, arg2), 
     156          this.assertEqual.bind(this, arg3), arg1, arg2, arg3 ); 
    157157        call(eventTest); 
    158158      } 
  • spinoffs/prototype/trunk/test/unit/hash.html

    r6481 r6555  
    134134     
    135135    testToJSON: function(){ with(this) { 
    136       assertEqual('{\"b\":[false,true],\"c\":{\"a\":\"hello!\"}}', 
     136      assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}', 
    137137        $H({'b': [undefined, false, true, undefined], c: {a: 'hello!'}}).toJSON()); 
    138138