Permalink
Browse files

changed the way of checking for the method to apply, using Arian style

added flatten to the list of the method to fix
removed useless always-true checking 
using short-circuit to avoid looking for all the elements if not on map
changed coding standard to adhere to mootools standards (i hope so :P)
  • Loading branch information...
kentaromiura committed Apr 10, 2012
1 parent 6567fa2 commit 96f7bfd925474ea24a5c8b97b3fc80a240df297a
Showing with 4 additions and 2 deletions.
  1. +4 −2 Source/Element/Element.js
@@ -200,10 +200,12 @@ if (object[1] == 1) Elements.implement('splice', function(){
Array.forEachMethod(function(method, name){
var wrap;
- if(name in {map:1,splice:1,slice:1,clone:1}){
+ if (({map: 1, splice: 1, slice: 1, clone: 1, flatten: 1})[name]){
wrap = function(){
var result = method.apply(this, arguments);
- if(typeOf(result) == 'array' && result.every(function(el){return typeOf(el) == 'element';})){
+ if (name != 'map' || result.every(function(el){
+ return typeOf(el) == 'element';
+ })){
result = new Elements(result);
}
return result;

0 comments on commit 96f7bfd

Please sign in to comment.