Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Class: arguments.callee.parent is no more necessary, as I've found…

… a very elegant and 100% safe way to handle this.parent correctly (its based on caller, and it just routes to arguments.callee.parent).

 - replaced all instances of arguments.callee.parent with this.parent.



git-svn-id: http://svn.mootools.net/trunk@1531 4db308c1-fb21-0410-9919-de62e267375e
  • Loading branch information...
commit 7a96c9cd80b4c3bbc0d0df34dc8501a612d0c638 1 parent 0798670
kamicane authored
View
4 Compatibility/Request/Request.JSON.js
@@ -7,14 +7,14 @@ JSON.Remote = new Class({
Extends: Request.JSON,
initialize: function(url, options){
- arguments.callee.parent(options);
+ this.parent(options);
this.onComplete = $empty;
this.url = url;
},
send: function(data){
if (!this.check(data)) return this;
- return arguments.callee.parent({url: this.url, data: {json: Json.encode(data)}});
+ return this.parent({url: this.url, data: {json: Json.encode(data)}});
},
failure: function(){
View
4 Compatibility/Request/Request.js
@@ -9,7 +9,7 @@ var XHR = new Class({
},
initialize: function(url, options){
- arguments.callee.parent(options);
+ this.parent(options);
this.url = url;
},
@@ -19,7 +19,7 @@ var XHR = new Class({
send: function(url, data){
if (!this.check(url, data)) return this;
- return arguments.callee.parent({url: url, data: data});
+ return this.parent({url: url, data: data});
},
success: function(text, xml){
View
2  Demos/CustomEvents/index.html
@@ -31,4 +31,4 @@
<div id="myScrollElement"><div></div></div>
<div id="myOtherDivElement"></div>
</body>
-</html>
+</html>
View
51 Source/Class/Class.js
@@ -56,29 +56,34 @@ Class.Mutators.Implements = function(self, klasses){
};
Class.Mutators.Extends = function(self, klass){
+
+ self.parent = function(){
+ return this.parent.caller.parent.apply(this, arguments);
+ };
+
klass = new klass($empty);
- for (var property in klass){
- var kp = klass[property];
- var sp = self[property];
- self[property] = (function(previous, current){
- if (current != undefined && previous != current){
- var type = $type(current);
- if (type != $type(previous)) return current;
- switch (type){
- case 'function':
- return function(){
- var previousParent = this.parent;
- if (!current.parent) current.parent = previous.bind(this);
- this.parent = current.parent;
- var value = current.apply(this, arguments);
- this.parent = previousParent;
- return value;
- };
- case 'object': return $merge(previous, current);
- default: return current;
- }
+
+ for (var property in klass) self[property] = (function(previous, current){
+
+ if (current != undefined && previous != current){
+
+ var type = $type(current), ptype = $type(previous);
+
+ if (type != ptype) return current;
+
+ switch (type){
+ case 'function':
+ return function(){
+ if (!current.parent) current.parent = previous.bind(this);
+ return current.apply(this, arguments);
+ };
+ case 'object': return $merge(previous, current);
+ default: return current;
}
- return previous;
- })(kp, sp);
- }
+
+ }
+
+ return previous;
+
+ })(klass[property], self[property]);
};
View
6 Source/Fx/Fx.Morph.js
@@ -12,7 +12,7 @@ Fx.Morph = new Class({
initialize: function(element, options){
this.element = this.subject = $(element);
- arguments.callee.parent(options);
+ this.parent(options);
},
set: function(now){
@@ -23,7 +23,7 @@ Fx.Morph = new Class({
compute: function(from, to, delta){
var now = {};
- for (var p in from) now[p] = arguments.callee.parent(from[p], to[p], delta);
+ for (var p in from) now[p] = this.parent(from[p], to[p], delta);
return now;
},
@@ -36,7 +36,7 @@ Fx.Morph = new Class({
from[p] = parsed.from;
to[p] = parsed.to;
}
- return arguments.callee.parent(from, to);
+ return this.parent(from, to);
}
});
View
4 Source/Fx/Fx.Tween.js
@@ -12,7 +12,7 @@ Fx.Tween = new Class({
initialize: function(element, options){
this.element = this.subject = $(element);
- arguments.callee.parent(options);
+ this.parent(options);
},
set: function(property, now){
@@ -29,7 +29,7 @@ Fx.Tween = new Class({
var args = Array.flatten(arguments);
this.property = this.options.property || args.shift();
var parsed = this.prepare(this.element, this.property, args);
- return arguments.callee.parent(parsed.from, parsed.to);
+ return this.parent(parsed.from, parsed.to);
}
});
View
2  Source/Plugins/Accordion.js
@@ -26,7 +26,7 @@ var Accordion = new Class({
initialize: function(){
var params = Array.link(arguments, {'container': Element.type, 'options': Object.type, 'togglers': $defined, 'elements': $defined});
- arguments.callee.parent(params.elements, params.options);
+ this.parent(params.elements, params.options);
this.togglers = $$(params.togglers);
this.container = $(params.container);
this.previous = -1;
View
8 Source/Plugins/Drag.Move.js
@@ -16,7 +16,7 @@ Drag.Move = new Class({
},
initialize: function(element, options){
- arguments.callee.parent(element, options);
+ this.parent(element, options);
this.droppables = $$(this.options.droppables);
this.container = $(this.options.container);
if (this.container && $type(this.container) != 'element') this.container = $(this.container.getDocument().body);
@@ -48,7 +48,7 @@ Drag.Move = new Class({
this.options.limit = {x: x, y: y};
}
- arguments.callee.parent(event);
+ this.parent(event);
},
checkAgainst: function(el){
@@ -71,7 +71,7 @@ Drag.Move = new Class({
},
drag: function(event){
- arguments.callee.parent(event);
+ this.parent(event);
if (this.droppables.length) this.checkDroppables();
},
@@ -79,7 +79,7 @@ Drag.Move = new Class({
this.checkDroppables();
this.fireEvent('onDrop', [this.element, this.overed]);
this.overed = null;
- return arguments.callee.parent(event);
+ return this.parent(event);
}
});
View
6 Source/Plugins/Fx.Elements.js
@@ -12,14 +12,14 @@ Fx.Elements = new Class({
initialize: function(elements, options){
this.elements = this.subject = $$(elements);
- arguments.callee.parent(options);
+ this.parent(options);
},
compute: function(from, to, delta){
var now = {};
for (var i in from){
var iFrom = from[i], iTo = to[i], iNow = now[i] = {};
- for (var p in iFrom) iNow[p] = arguments.callee.parent(iFrom[p], iTo[p], delta);
+ for (var p in iFrom) iNow[p] = this.parent(iFrom[p], iTo[p], delta);
}
return now;
},
@@ -43,7 +43,7 @@ Fx.Elements = new Class({
iTo[p] = parsed.to;
}
}
- return arguments.callee.parent(from, to);
+ return this.parent(from, to);
}
});
View
4 Source/Plugins/Fx.Scroll.js
@@ -17,7 +17,7 @@ Fx.Scroll = new Class({
initialize: function(element, options){
this.element = this.subject = $(element);
- arguments.callee.parent(options);
+ this.parent(options);
var cancel = this.cancel.bind(this, false);
if ($type(this.element) != 'element') this.element = $(this.element.getDocument().body);
@@ -57,7 +57,7 @@ Fx.Scroll = new Class({
else values[z] = scroll[z];
values[z] += this.options.offset[z];
}
- return arguments.callee.parent([scroll.x, scroll.y], [values.x, values.y]);
+ return this.parent([scroll.x, scroll.y], [values.x, values.y]);
},
toTop: function(){
View
4 Source/Plugins/Fx.Slide.js
@@ -20,7 +20,7 @@ Fx.Slide = new Class({
if (this.open && Browser.Engine.webkit419) this.element.dispose().inject(this.wrapper);
}, true);
this.element = this.subject = $(element);
- arguments.callee.parent(options);
+ this.parent(options);
var wrapper = this.element.retrieve('wrapper');
this.wrapper = wrapper || new Element('div', {
styles: $extend(this.element.getStyles('margin', 'position'), {'overflow': 'hidden'})
@@ -69,7 +69,7 @@ Fx.Slide = new Class({
case 'out': start = caseOut; break;
case 'toggle': start = (this.wrapper['offset' + this.layout.capitalize()] == 0) ? caseIn : caseOut;
}
- return arguments.callee.parent(start[0], start[1]);
+ return this.parent(start[0], start[1]);
},
slideIn: function(mode){
View
2  Source/Plugins/SmoothScroll.js
@@ -13,7 +13,7 @@ var SmoothScroll = new Class({
initialize: function(options, context){
context = context || document;
var doc = context.getDocument(), win = context.getWindow();
- arguments.callee.parent(doc, options);
+ this.parent(doc, options);
this.links = (this.options.links) ? $$(this.options.links) : $$(doc.links);
var location = win.location.href.match(/^[^#]*/)[0] + '#';
this.links.each(function(link){
View
2  Source/Request/Request.JSON.js
@@ -15,7 +15,7 @@ Request.JSON = new Class({
},
initialize: function(options){
- arguments.callee.parent(options);
+ this.parent(options);
this.headers.extend({'Accept': 'application/json', 'X-Request': 'JSON'});
},
View
2  Specs/Class/Class.js
@@ -61,7 +61,7 @@ describe('Class.constructor', {
var Cat = new Class({ Extends: Animal,
initialize: function(name, color){
- arguments.callee.parent(name);
+ this.parent(name);
this.color = color;
this.ferocious = false;
},
Please sign in to comment.
Something went wrong with that request. Please try again.