From d3e186b4a3ed6c6fd23c121d8fafae494c05799d Mon Sep 17 00:00:00 2001 From: itozyun Date: Wed, 4 Jun 2014 13:21:37 +0900 Subject: [PATCH] Version 0.6.44, fixed X.Class for safari1. --- 0.6.x/js/core/00_X.js | 2 +- 0.6.x/js/core/00_builtin.js | 53 ++++++++++++++++++++++++++++++++++++++++++ 0.6.x/js/core/01_XUa.js | 11 ++++----- 0.6.x/js/core/02_XType.js | 9 +++---- 0.6.x/js/core/04_XClass.js | 18 +++++++++++--- 0.6.x/js/core/05_XTimer.js | 6 ++--- 0.6.x/js/dom/11_XDomNode.js | 12 ++++------ 0.6.x/js/dom/12_XDomEvent.js | 4 ++-- 0.6.x/js/dom/18_XDomQuery.js | 14 +++++------ 0.6.x/js/dom/22_XDomBuilder.js | 2 +- 10 files changed, 97 insertions(+), 34 deletions(-) diff --git a/0.6.x/js/core/00_X.js b/0.6.x/js/core/00_X.js index eba12b0..72023b5 100644 --- a/0.6.x/js/core/00_X.js +++ b/0.6.x/js/core/00_X.js @@ -13,7 +13,7 @@ X.getTime = Date.now ? new Function( 'return Date.now()' ) : new Function( 'retu X.emptyFunction = new Function; - // defer の場合もあるので、document.readyState を見る + // defer の場合もあるので、document.readyState を見る MacIE で false X.inHead = (function( s ){ if( !s ) return false; if( !s.length ) return false; // Safari1.3 312.8 でerror diff --git a/0.6.x/js/core/00_builtin.js b/0.6.x/js/core/00_builtin.js index 6d4b1a1..da90d1a 100644 --- a/0.6.x/js/core/00_builtin.js +++ b/0.6.x/js/core/00_builtin.js @@ -215,4 +215,57 @@ if (window.ActiveXObject ? !Number.prototype.toFixed : (!navigator.taintEnabled }; })(); */ +/* + * Safari の JavaScript の不備 + * http://nanto.asablo.jp/blog/2006/01/13/209495 + * + * web.paulownia.jp - JavaScriptとクロージャ + * https://web.archive.org/web/20070526063400/http://web.paulownia.jp/script/oop/closure.html + * MacOSX 10.3のsafariにはhasOwnPropertyが実装されていないので、独自に追加する必要があります。 + */ +/*----------------- +result | 1 | 2 | 3 | +this | NaN | | | NaN | NaN | NaN | +_proto_ | | NaN | | NaN | | NaN | +_super_ | | | NaN | | NaN | NaN | +*/ +/* +Object.prototype.hasOwnProperty || (Object.prototype.hasOwnProperty = function( p ){ + var _proto_ = this.constructor && this.constructor.prototype, + v = this[ p ], + nan = v !== v; // isNaN + save, r = false; + if( nan ){ + // NaN の判定は完全に chain を辿る必要がある + save = _proto_[ p ]; + _proto_[ p ] = true; + r = this[ p ] !== this[ p ]; // isNaN + + delete _proto_[ p ]; + // もっと深い chain で定義されていた. + if( this[ p ] !== this[ p ] ) return r; // 1 + // __proto__ で定義されていた. + _proto_[ p ] = save; + } else + if( p in this ){ + if( + !_proto_ || + !( p in _proto_ ) || + ( _proto_[ p ] !== v ) + ) return true; + + // this と __proto__ に同名で同値が書かれている可能性あり + + save = _proto_[ p ]; + _proto_[ p ] = v + ' '; + r = v === this[ p ]; + + delete _proto_[ p ]; + // もっと深い chain で定義されていた. + if( _proto_[ p ] === v ) return r; + // __proto__ で定義されていた. + _proto_[ p ] = save; + }; + return r; + }); */ \ No newline at end of file diff --git a/0.6.x/js/core/01_XUa.js b/0.6.x/js/core/01_XUa.js index ed483b6..4d7e44b 100644 --- a/0.6.x/js/core/01_XUa.js +++ b/0.6.x/js/core/01_XUa.js @@ -25,6 +25,7 @@ X.UA = (function( n, undefined ){ if( document.all ){ acme.ActiveX = !!window[ 'ActiveXObject' ]; acme.IE = parseFloat(dav.split("MSIE ")[1]) || parseFloat(dua.split("rv:")[1]) || 0; + acme.MacIE = !!dav.indexOf( 'Mac_PowerPC' ) || !!dav.indexOf( 'Mac_PPC' ) || !!dav.indexOf( 'Mac_68K' ); acme.IEMobile = dua.toLowerCase().indexOf( 'iemobile' ) !== -1 || dua.toLowerCase().indexOf( 'windows phone' ) !== -1; return acme; @@ -93,7 +94,7 @@ X.UA = (function( n, undefined ){ return acme; })( navigator ); - +/* ie5 でerror... X.inObject = X.UA.IE && X.UA.IE < 5 ? // TODO JScript で判定 (function( name, obj ){ var p; @@ -104,12 +105,11 @@ X.inObject = X.UA.IE && X.UA.IE < 5 ? // TODO JScript で判定 }; return false; }) : - new Function( 'a,b', 'return a in b' ); - + new Function( 'a,b', 'return a in b' ); // Safari 3.1 未満は開発コンソールがない! // http://shimax.cocolog-nifty.com/search/2006/09/safarijavascrip_c54d.html -/*@+debug[*/ + if( X.UA.Safari && X.UA.WebKit < 525.13 ){ window.onerror = function( x, y, z ){ var n = String.fromCharCode( 10 ); @@ -117,9 +117,8 @@ if( X.UA.Safari && X.UA.WebKit < 525.13 ){ return true; }; }; -/*]@+debug*/ if( X.UA.IE && X.UA.IE < 7 ){ // error @ NN7.2 // bonus: hotfix for IE6 SP1 (bug KB823727) document.execCommand && document.execCommand( 'BackgroundImageCache', false, true ); -}; +};*/ diff --git a/0.6.x/js/core/02_XType.js b/0.6.x/js/core/02_XType.js index 7af1026..ecd16e6 100644 --- a/0.6.x/js/core/02_XType.js +++ b/0.6.x/js/core/02_XType.js @@ -13,9 +13,10 @@ X.Type = { return typeof v === 'function'; }, isArray : - X.UA.IE && X.UA.IE < 5 ? (function(v){ return v && typeof v.length === 'number';}) : + X.UA.IE && ( X.UA.IE < 5 || X.UA.MacIE ) ? (function(v){ return v && typeof v.length === 'number';}) : window['Array'] ? (new Function('v', 'return v instanceof Array;')) : (function(v){ return Object.prototype.toString.call(v) === '[object Array]';}), + isBoolean : function(v) { return typeof v === 'boolean'; }, @@ -26,11 +27,11 @@ X.Type = { return typeof v === 'number'; }, isFinite : function(v){ - return X.Type.isNumber(v) === true && isFinite(v); + return X.Type.isNumber(v) && isFinite(v); }, isHTMLElement : - // ie4 - X.UA.IE && X.UA.IE < 5 ? (function(v){ return v && v.tagName && v.all;}) : + // ie4 or MacIE5.23 + X.UA.IE && ( X.UA.IE < 5 || X.UA.MacIE ) ? (function(v){ return v && v.tagName && v.all;}) : window['HTMLElement'] ? (new Function('v', 'return v instanceof HTMLElement')) : (function(v){ return v && v.nodeType === 1 && v.appendChild;}), /* diff --git a/0.6.x/js/core/04_XClass.js b/0.6.x/js/core/04_XClass.js index 4e3b5f8..7f2eeb9 100644 --- a/0.6.x/js/core/04_XClass.js +++ b/0.6.x/js/core/04_XClass.js @@ -240,11 +240,17 @@ X.Class = ( function(){ klass = new Function( 'var a=arguments,f=a.callee;if(f.__new)return f.__new(a)' ); klass.__new = C; - if( X.UA.Safari && X.UA.Safari < 2 ){ + klass.superClassOf = X.Class._superClassOf; + klass.subClassOf = X.Class._subClassOf; + + if( X.UA.Safari && X.UA.Safari < 2 ){ // Webkit で判定、Gecko もこちら // Safari では、prototype の差し替えができない, 1.3 で確認 // あとから super class にプロパティを足しても、sub に伝播しない、、、 - traits && X.Class._override( klass.prototype, traits, false ); - X.Class._override( X.Class._override( klass.prototype, CommonProps, false ), props, true ); + //traits && X.Class._override( klass.prototype, traits, false ); + //X.Class._override( X.Class._override( klass.prototype, CommonProps, false ), props, true ); + // F = new Function; F.prototype = traits; traits.constructor = klass; klass.prototype = new F; + X.Class._override( X.Class._override( traits || klass.prototype, props, true ), CommonProps, false ); + if( traits ) klass.prototype.__proto__ = traits; } else { klass.prototype = X.Class._override( X.Class._override( traits || klass.prototype, props, true ), CommonProps, false ); klass.prototype.constructor = klass; @@ -352,6 +358,12 @@ X.Class = ( function(){ }; }; return target; + }, + _superClassOf : function(){ + + }, + _subClassOf : function(){ + } }; })(); \ No newline at end of file diff --git a/0.6.x/js/core/05_XTimer.js b/0.6.x/js/core/05_XTimer.js index 058b8c4..1dc1673 100644 --- a/0.6.x/js/core/05_XTimer.js +++ b/0.6.x/js/core/05_XTimer.js @@ -193,7 +193,7 @@ if( X.UA.iOS ){ } ); }; -if( X.UA.IE && X.UA.IE < 5 ){ - X.Timer[ '_ie4_loop' ] = X.Timer._loop; - X.Timer._loop = 'X.Timer._ie4_loop()'; +if( X.UA.IE && ( X.UA.IE < 5 || X.UA.MacIE ) ){ + X.Timer[ '_ie_loop' ] = X.Timer._loop; + X.Timer._loop = 'X.Timer._ie_loop()'; }; diff --git a/0.6.x/js/dom/11_XDomNode.js b/0.6.x/js/dom/11_XDomNode.js index ae2901f..86c75db 100644 --- a/0.6.x/js/dom/11_XDomNode.js +++ b/0.6.x/js/dom/11_XDomNode.js @@ -1,4 +1,3 @@ - X.Dom.Dirty = { CLEAN : 0, CHILD_IS_DIRTY : 1, @@ -12,8 +11,6 @@ X.Dom.Dirty = { IE4_TEXTNODE_FIX : 256 }; -ie55 = 7; - X.Dom.State = { DESTROYED : 0, EXIST : 1, @@ -28,9 +25,11 @@ X.Dom.State = { HAS_HEIGHT_LENGTH : 512, HAS_HEIGHT_PERCENT : 1024, IE4_ONLY_TEXT : 2048, - IE5_DISPLAY_NONE_FIX : 5 <= X.UA.IE && X.UA.IE < ie55 ? 4096 : 0 + IE5_DISPLAY_NONE_FIX : 5 <= X.UA.IE && X.UA.IE < 5.5 ? 4096 : 0 // MacIE5.2- は ? }; +X.Dom._strictElmCreation = X.UA.IE && X.UA.IE < 9;// && !X.UA.MacIE; + /* * Node( rawElement | rawTextnode | htmlString | textString ) */ @@ -856,7 +855,6 @@ Node.prototype._startUpdate = function(){ Node._html._dirty ? Node._html._commitUpdate() : this._commitUpdate(); - //X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.AFTER_UPDATE ] && X.Dom.dispatch( { type : X.Dom.Event.AFTER_UPDATE } ); X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.AFTER_UPDATE ] && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.AFTER_UPDATE } ); //this._rawNode.style.visibility = tmp; }; @@ -1111,7 +1109,7 @@ Node.prototype._actualCreate = }; this._isNew = true; this._rawNode = elm = - ie55 <= X.UA.IE && X.UA.IE < 9 ? + X.Dom._strictElmCreation ? document.createElement( [ '<', this._tag, ' UID="', this._uid, '"', @@ -1202,7 +1200,7 @@ Node.prototype._afterActualCreate = // this._dirty = X.Dom.Dirty.CSS | X.Dom.Dirty.IE_FILTER; // this._updateRawNode( elm ); //} else - if( !X.UA.IE || X.UA.IE < ie55 || 9 <= X.UA.IE ){ + if( !X.Dom._strictElmCreation ){ elm.UID = this._uid; this._newAttrs = this._attrs; this._dirty = X.Dom.Dirty.ID | X.Dom.Dirty.CLASSNAME | X.Dom.Dirty.CSS | X.Dom.Dirty.ATTR | X.Dom.Dirty.IE_FILTER; diff --git a/0.6.x/js/dom/12_XDomEvent.js b/0.6.x/js/dom/12_XDomEvent.js index 2fc5817..b29f3f8 100644 --- a/0.6.x/js/dom/12_XDomEvent.js +++ b/0.6.x/js/dom/12_XDomEvent.js @@ -228,7 +228,7 @@ X.Dom.Node.prototype._addEvent = this._rawNode.attachEvent( 'on' + type, this._handleEvent ); }) : (function( type ){ - var elm = this._ie4getRawNode(); + var elm = this._rawNode || this._ie4getRawNode && this._ie4getRawNode(); if( !elm ) return; this._handleEvent = elm[ 'on' + type ] = this._handleEvent || X.Callback.create( this ); }); @@ -278,7 +278,7 @@ X.Dom.Node.prototype._removeEvent = }; }) : (function( type ){ - var elm = this._rawNode || this._ie4getRawNode(); + var elm = this._rawNode || this._ie4getRawNode && this._ie4getRawNode(); if( !elm ) return; elm[ 'on' + type ] = X.emptyFunction; elm[ 'on' + type ] = ''; diff --git a/0.6.x/js/dom/18_XDomQuery.js b/0.6.x/js/dom/18_XDomQuery.js index eece774..12d3d75 100644 --- a/0.6.x/js/dom/18_XDomQuery.js +++ b/0.6.x/js/dom/18_XDomQuery.js @@ -239,7 +239,7 @@ X.Dom.Query._parse = function( query, last ){ // 以下、パースと探索 for( ; queryString.length; ){ - console.log( 'queryString[' + queryString + ']' ); + //console.log( 'queryString[' + queryString + ']' ); // 初期化処理 if( !parsed ){ @@ -253,7 +253,7 @@ X.Dom.Query._parse = function( query, last ){ queryString = queryString.substr( parsed[ 0 ] ); parsed = parsed[ 1 ]; - console.log( 'X.Dom.Query._parse ' + parsed ); + //console.log( 'X.Dom.Query._parse ' + parsed ); if( parsed === 5 ){ isMulti = true; @@ -280,7 +280,7 @@ X.Dom.Query._parse = function( query, last ){ if( combinator !== 0 ){ parents = xnodes; xnodes = []; - console.log( 'cobinator !== 0 ' + parents.length + ' : ' + xnodes.length ); + //console.log( 'cobinator !== 0 ' + parents.length + ' : ' + xnodes.length ); }; }; @@ -331,12 +331,12 @@ X.Dom.Query._parse = function( query, last ){ default : if( combinator === 1 || ( isStart && selector < 7 ) ){ - console.log( l + ' > ' + xnodes.length + ' tag:' + tagName ); + //console.log( l + ' > ' + xnodes.length + ' tag:' + tagName ); for( ; i < l; ++i ){ xnode = parents[ i ]; xnode._xnodes && xnode._xnodes.length && X.Dom.Query._fetchElements( xnodes, xnode, isAll ? null : tagName ); }; - console.log( l + ' >> ' + xnodes.length + ' tag:' + tagName ); + //console.log( l + ' >> ' + xnodes.length + ' tag:' + tagName ); }; }; @@ -477,9 +477,9 @@ X.Dom.Query._parse = function( query, last ){ isNot = false; parsed = null; - console.log( '//end :' + ( xnodes && xnodes.length ) ); + //console.log( '//end :' + ( xnodes && xnodes.length ) ); }; - console.log( 'multi:' + ( xnodes && xnodes.length ) ); + //console.log( 'multi:' + ( xnodes && xnodes.length ) ); // tree 順に並び替え、同一要素の排除 if( isMulti ){ diff --git a/0.6.x/js/dom/22_XDomBuilder.js b/0.6.x/js/dom/22_XDomBuilder.js index 7e1257f..b33b2ec 100644 --- a/0.6.x/js/dom/22_XDomBuilder.js +++ b/0.6.x/js/dom/22_XDomBuilder.js @@ -21,7 +21,7 @@ X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, // textarea の内容を控えて、消す。xnode tree 構築後に復帰。でないと、html パースでこける // cleanup tree - (function/*cleanUpTree*/( elm, skip, head ){ + X.UA.MacIE || (function/*cleanUpTree*/( elm, skip, head ){ var nodes = X.copyArray( elm.childNodes ), i = 0, l = nodes.length, -- 2.11.0