prototype: Give the parens some breathing room
This commit is contained in:
parent
7544938291
commit
fb0013a193
14
src/array.js
14
src/array.js
|
@ -100,18 +100,18 @@ Object.extend(Array.prototype, {
|
|||
|
||||
Array.prototype.toArray = Array.prototype.clone;
|
||||
|
||||
function $w(string){
|
||||
function $w(string) {
|
||||
string = string.strip();
|
||||
return string ? string.split(/\s+/) : [];
|
||||
}
|
||||
|
||||
if(Prototype.Browser.Opera){
|
||||
Array.prototype.concat = function(){
|
||||
if (Prototype.Browser.Opera){
|
||||
Array.prototype.concat = function() {
|
||||
var array = [];
|
||||
for(var i = 0, length = this.length; i < length; i++) array.push(this[i]);
|
||||
for(var i = 0, length = arguments.length; i < length; i++) {
|
||||
if(arguments[i].constructor == Array) {
|
||||
for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
|
||||
for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
|
||||
for (var i = 0, length = arguments.length; i < length; i++) {
|
||||
if (arguments[i].constructor == Array) {
|
||||
for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
|
||||
array.push(arguments[i][j]);
|
||||
} else {
|
||||
array.push(arguments[i]);
|
||||
|
|
|
@ -99,7 +99,7 @@ Object.extend(Number.prototype, {
|
|||
return '0'.times(length - string.length) + string;
|
||||
},
|
||||
|
||||
toJSON: function(){
|
||||
toJSON: function() {
|
||||
return isFinite(this) ? this.toString() : 'null';
|
||||
}
|
||||
});
|
||||
|
|
16
src/dom.js
16
src/dom.js
|
@ -421,9 +421,9 @@ if (Prototype.Browser.Opera) {
|
|||
case 'top':
|
||||
case 'right':
|
||||
case 'bottom':
|
||||
if(Element._getStyle(element, 'position') == 'static') return null;
|
||||
if (Element._getStyle(element, 'position') == 'static') return null;
|
||||
default: return Element._getStyle(element, style);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
else if (Prototype.Browser.IE) {
|
||||
|
@ -480,17 +480,13 @@ else if (Prototype.Browser.IE) {
|
|||
div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>';
|
||||
depth = 4;
|
||||
}
|
||||
$A(element.childNodes).each(function(node){
|
||||
element.removeChild(node)
|
||||
});
|
||||
depth.times(function(){ div = div.firstChild });
|
||||
|
||||
$A(div.childNodes).each(
|
||||
function(node){ element.appendChild(node) });
|
||||
$A(element.childNodes).each(function(node) { element.removeChild(node) });
|
||||
depth.times(function() { div = div.firstChild });
|
||||
$A(div.childNodes).each(function(node) { element.appendChild(node) });
|
||||
} else {
|
||||
element.innerHTML = html.stripScripts();
|
||||
}
|
||||
setTimeout(function() {html.evalScripts()}, 10);
|
||||
setTimeout(function() { html.evalScripts() }, 10);
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ Object.extend(Hash, {
|
|||
|
||||
toJSON: function(object) {
|
||||
var results = [];
|
||||
this.prototype._each.call(object, function(pair){
|
||||
this.prototype._each.call(object, function(pair) {
|
||||
var value = Object.toJSON(pair.value);
|
||||
if (value !== undefined) results.push(pair.key.toJSON() + ':' + value);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Object.extend(String, {
|
||||
interpret: function(value){
|
||||
interpret: function(value) {
|
||||
return value == null ? '' : String(value);
|
||||
},
|
||||
specialChar: {
|
||||
|
@ -85,7 +85,7 @@ Object.extend(String.prototype, {
|
|||
var div = document.createElement('div');
|
||||
div.innerHTML = this.stripTags();
|
||||
return div.childNodes[0] ? (div.childNodes.length > 1 ?
|
||||
$A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) :
|
||||
$A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
|
||||
div.childNodes[0].nodeValue) : '';
|
||||
},
|
||||
|
||||
|
@ -159,15 +159,15 @@ Object.extend(String.prototype, {
|
|||
return "'" + escapedString.replace(/'/g, '\\\'') + "'";
|
||||
},
|
||||
|
||||
toJSON: function(){
|
||||
toJSON: function() {
|
||||
return this.inspect(true);
|
||||
},
|
||||
|
||||
evalJSON: function(sanitize){
|
||||
evalJSON: function(sanitize) {
|
||||
try {
|
||||
if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this)))
|
||||
return eval('(' + this + ')');
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
throw new SyntaxError('Badly formated JSON string: ' + this.inspect());
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue