Changeset 38325

Show
Ignore:
Timestamp:
08/22/10 14:57:47 (3 years ago)
Author:
machu
Message:

add Array.prototype map function for IE8

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/js/draft.js

    r38286 r38325  
    88 
    99if (!localStorage) { return; } 
     10 
     11// for compatibility (ex: IE8) 
     12// from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/Map 
     13if (!Array.prototype.map) { 
     14  Array.prototype.map = function(fun /*, thisp*/) { 
     15    var len = this.length >>> 0; 
     16    if (typeof fun != "function") 
     17      throw new TypeError(); 
     18 
     19    var res = new Array(len); 
     20    var thisp = arguments[1]; 
     21    for (var i = 0; i < len; i++) { 
     22      if (i in this) 
     23      res[i] = fun.call(thisp, this[i], i, this); 
     24    } 
     25 
     26    return res; 
     27  }; 
     28} 
    1029 
    1130var Draft = function(storage, text) {