prototype: Add extra spacing so Array#toJSON and Hash#toJSON generate YAML-loadable JSON. Closes #7883.
This commit is contained in:
parent
193104ac33
commit
643b7bec37
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Add extra spacing so Array#toJSON and Hash#toJSON generate YAML-loadable JSON. Closes #7883. [Andrew Dupont]
|
||||
|
||||
* Fix Form.request for forms containing an input element with name="action". Closes #8063. [Thomas Fuchs, Mislav Marohnić]
|
||||
|
||||
* Make Event.element extend the returned element. Closes #7870. [Thomas Fuchs]
|
||||
|
@ -109,7 +109,7 @@ Object.extend(Array.prototype, {
|
||||
var value = Object.toJSON(object);
|
||||
if (value !== undefined) results.push(value);
|
||||
});
|
||||
return '[' + results.join(',') + ']';
|
||||
return '[' + results.join(', ') + ']';
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -42,9 +42,9 @@ Object.extend(Object, {
|
||||
for (var property in object) {
|
||||
var value = Object.toJSON(object[property]);
|
||||
if (value !== undefined)
|
||||
results.push(property.toJSON() + ':' + value);
|
||||
results.push(property.toJSON() + ': ' + value);
|
||||
}
|
||||
return '{' + results.join(',') + '}';
|
||||
return '{' + results.join(', ') + '}';
|
||||
},
|
||||
|
||||
keys: function(object) {
|
||||
|
@ -28,9 +28,9 @@ Object.extend(Hash, {
|
||||
var results = [];
|
||||
this.prototype._each.call(object, function(pair) {
|
||||
var value = Object.toJSON(pair.value);
|
||||
if (value !== undefined) results.push(pair.key.toJSON() + ':' + value);
|
||||
if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value);
|
||||
});
|
||||
return '{' + results.join(',') + '}';
|
||||
return '{' + results.join(', ') + '}';
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -123,8 +123,8 @@
|
||||
testToJSON: function(){ with(this) {
|
||||
assertEqual('[]', [].toJSON());
|
||||
assertEqual('[\"a\"]', ['a'].toJSON());
|
||||
assertEqual('[\"a\",1]', ['a', 1].toJSON());
|
||||
assertEqual('[\"a\",{\"b\":null}]', ['a', {'b': null}].toJSON());
|
||||
assertEqual('[\"a\", 1]', ['a', 1].toJSON());
|
||||
assertEqual('[\"a\", {\"b\": null}]', ['a', {'b': null}].toJSON());
|
||||
}},
|
||||
|
||||
testReduce: function(){ with(this) {
|
||||
|
@ -84,7 +84,7 @@
|
||||
methodWithBindArgumentsAndArguments.bind({hi:'withBindArgsAndArgs'},'arg1','arg2')('arg3','arg4');
|
||||
assertEqual('withBindArgsAndArgs,arg1,arg2,arg3,arg4', globalBindTest);
|
||||
}},
|
||||
|
||||
|
||||
testObjectInspect: function() { with(this) {
|
||||
assertEqual('undefined', Object.inspect());
|
||||
assertEqual('undefined', Object.inspect(undefined));
|
||||
@ -99,14 +99,14 @@
|
||||
assertEqual('\"\"', Object.toJSON(''));
|
||||
assertEqual('[]', Object.toJSON([]));
|
||||
assertEqual('[\"a\"]', Object.toJSON(['a']));
|
||||
assertEqual('[\"a\",1]', Object.toJSON(['a', 1]));
|
||||
assertEqual('[\"a\",{\"b\":null}]', Object.toJSON(['a', {'b': null}]));
|
||||
assertEqual('{\"a\":\"hello!\"}', Object.toJSON({a: 'hello!'}));
|
||||
assertEqual('[\"a\", 1]', Object.toJSON(['a', 1]));
|
||||
assertEqual('[\"a\", {\"b\": null}]', Object.toJSON(['a', {'b': null}]));
|
||||
assertEqual('{\"a\": \"hello!\"}', Object.toJSON({a: 'hello!'}));
|
||||
assertEqual('{}', Object.toJSON({}));
|
||||
assertEqual('{}', Object.toJSON({a: undefined, b: undefined, c: Prototype.K}));
|
||||
assertEqual('{\"b\":[false,true],\"c\":{\"a\":\"hello!\"}}',
|
||||
assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}',
|
||||
Object.toJSON({'b': [undefined, false, true, undefined], c: {a: 'hello!'}}));
|
||||
assertEqual('{\"b\":[false,true],\"c\":{\"a\":\"hello!\"}}',
|
||||
assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}',
|
||||
Object.toJSON($H({'b': [undefined, false, true, undefined], c: {a: 'hello!'}})));
|
||||
assertEqual('true', Object.toJSON(true));
|
||||
assertEqual('false', Object.toJSON(false));
|
||||
@ -148,12 +148,12 @@
|
||||
div.setAttribute('id','test-'+i);
|
||||
document.body.appendChild(div);
|
||||
var tobj = new TestObj();
|
||||
var eventTest = {test:true};
|
||||
var eventTest = { test: true };
|
||||
var call = tobj.assertingEventHandler.bindAsEventListener(tobj,
|
||||
this.assertEqual.bind(this,eventTest),
|
||||
this.assertEqual.bind(this,arg1),
|
||||
this.assertEqual.bind(this,arg2),
|
||||
this.assertEqual.bind(this,arg3), arg1, arg2, arg3 );
|
||||
this.assertEqual.bind(this, eventTest),
|
||||
this.assertEqual.bind(this, arg1),
|
||||
this.assertEqual.bind(this, arg2),
|
||||
this.assertEqual.bind(this, arg3), arg1, arg2, arg3 );
|
||||
call(eventTest);
|
||||
}
|
||||
},
|
||||
|
@ -133,7 +133,7 @@
|
||||
}},
|
||||
|
||||
testToJSON: function(){ with(this) {
|
||||
assertEqual('{\"b\":[false,true],\"c\":{\"a\":\"hello!\"}}',
|
||||
assertEqual('{\"b\": [false, true], \"c\": {\"a\": \"hello!\"}}',
|
||||
$H({'b': [undefined, false, true, undefined], c: {a: 'hello!'}}).toJSON());
|
||||
|
||||
assertEqual('E', eval('(' + $H(Fixtures.dangerous).toJSON() + ')')._each);
|
||||
|
Loading…
Reference in New Issue
Block a user