OSDN Git Service

Version 0.6.49, fix for xnode.attr(name).
[pettanr/clientJs.git] / 0.6.x / js / core / 00_builtin.js
index f2a5207..3f8f676 100644 (file)
@@ -12,7 +12,10 @@ Function.prototype.apply || (Function.prototype.apply = function (x, y) {
        if( x === window ){\r
                x.__apply = void 0;\r
        } else {\r
-               delete x.__apply ? x.__apply : x.constructor.prototype.__apply ;\r
+               if( x.constructor && x.constructor.prototype.__apply ){\r
+                       delete x.constructor.prototype.__apply;\r
+               } else\r
+               if( x.__apply ) delete x.__apply;\r
        };\r
        \r
        x.__apply = this;\r
@@ -33,15 +36,19 @@ Function.prototype.apply || (Function.prototype.apply = function (x, y) {
                        a = [];\r
                        for (i = 0; i < j; ++i)\r
                                a[i] = 'y[' + i + ']';\r
-                       r = eval('x.__apply(' + a.join(',') + ')');\r
+                       //r = eval('x.__apply(' + a.join(',') + ')');\r
+                       // closuer compiler 対策\r
+                       r = (new Function( 'x,y', 'return x.__apply(' + a.join(',') + ')' ))( x, y );\r
                        break;\r
        };\r
-       // delete x.__apply ? x.__apply : x.constructor.prototype.__apply ;\r
        // ie5\r
        if( x === window ){\r
                x.__apply = void 0;\r
        } else {\r
-               delete x.__apply ? x.__apply : x.constructor.prototype.__apply ;\r
+               if( x.constructor && x.constructor.prototype.__apply ){\r
+                       delete x.constructor.prototype.__apply;\r
+               } else\r
+               if( x.__apply ) delete x.__apply;\r
        };\r
        return r;\r
 });\r
@@ -148,6 +155,7 @@ window.encodeURIComponent || (window.encodeURIComponent = function (x) {
        });\r
 });\r
 \r
+// 手抜き\r
 window.decodeURI || (window.decodeURI = function (x) {\r
        return ("" + x).replace(/%(E(0%[AB]|[1-CEF]%[89AB]|D%[89])[0-9A-F]|C[2-9A-F]|D[0-9A-F])%[89AB][0-9A-F]|%[0-7][0-9A-F]/ig, function (s) {\r
                var c = parseInt(s.substring(1), 16);\r
@@ -160,8 +168,8 @@ window.decodeURI || (window.decodeURI = function (x) {
 });\r
 */\r
 \r
-// 手抜き\r
-window.decodeURIComponent || (window.decodeURIComponent = window.decodeURI);\r
+\r
+//window.decodeURIComponent || (window.decodeURIComponent = window.decodeURI);\r
 \r
 \r
 /*\r
@@ -169,6 +177,7 @@ window.decodeURIComponent || (window.decodeURIComponent = window.decodeURI);
  */\r
 \r
 // replace(RegExp, Function)対応\r
+/*\r
 if (window.ActiveXObject ? !Number.prototype.toFixed : (!navigator.taintEnabled && !document.createElement("input").setSelectionRange))\r
        (function () {\r
                var g = String.prototype.replace;\r
@@ -204,4 +213,54 @@ if (window.ActiveXObject ? !Number.prototype.toFixed : (!navigator.taintEnabled
                        }\r
                        return g.call(s, x, z);\r
                };\r
-       })();
\ No newline at end of file
+       })(); */\r
+       \r
+/*\r
+ * Safari の JavaScript の不備 \r
+ * http://nanto.asablo.jp/blog/2006/01/13/209495\r
+ * \r
+ * web.paulownia.jp - JavaScriptとクロージャ\r
+ * https://web.archive.org/web/20070526063400/http://web.paulownia.jp/script/oop/closure.html\r
+ * MacOSX 10.3のsafariにはhasOwnPropertyが実装されていないので、独自に追加する必要があります。\r
+ */\r
+/*\r
+Object.prototype.hasOwnProperty || (Object.prototype.hasOwnProperty = function( p ){\r
+               var proto = this.constructor && this.constructor.prototype,\r
+                       __p__ = proto && ( '__proto__' in proto ) && proto.__proto__,\r
+                       v     = this[ p ],\r
+                       nan   = v !== v, // isNaN\r
+                       r = false, save;\r
+               \r
+               if( __p__ ) proto.__proto__ = v === null ? undefined : null;\r
+               \r
+               if( nan ){\r
+                       if( proto[ p ] !== proto[ p ] ){ // proto is NaN\r
+                               proto[ p ] = 0; // different value\r
+                               r = this[ p ] !== this[ p ]; // isNaN\r
+                               proto[ p ] = NaN; // proto で定義されていた.\r
+                       } else {\r
+                               r = true;\r
+                       };\r
+               } else\r
+               if( p in this ){\r
+                       if( !proto || !( p in proto ) || ( proto[ p ] !== v ) ){\r
+                               r = true;\r
+                       } else {\r
+                               // this と proto に同名で同値が書かれている可能性あり\r
+                               save = proto[ p ];\r
+                               proto[ p ] = v + ' '; // different value\r
+                               r = v === this[ p ];\r
+                               \r
+                               delete proto[ p ];\r
+                       \r
+                               if( proto[ p ] !== v ){\r
+                                       // proto で定義されていた.\r
+                                       proto[ p ] = save;                              \r
+                               };\r
+                       };\r
+               };\r
+               \r
+               if( __p__ ) proto.__proto__ = __p__;\r
+               \r
+               return r;\r
+  });*/\r