X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F08_XNodeSelector.js;h=7d18c8b424cb07a1b2b24f8a242db8c4db76167f;hb=9a3ec59dd9eafb9fde293ee2f112e168af1e62bc;hp=1d1dbb79cc4fcfbd9363ec25424f1551b317f3ad;hpb=db532e067114718c69d226d08979d236416ae73d;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/02_dom/08_XNodeSelector.js b/0.6.x/js/02_dom/08_XNodeSelector.js index 1d1dbb7..7d18c8b 100644 --- a/0.6.x/js/02_dom/08_XNodeSelector.js +++ b/0.6.x/js/02_dom/08_XNodeSelector.js @@ -56,7 +56,10 @@ var // TODO { a : 1, A : 2, _ : 3,,, } X_Node_Selector__ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-0123456789\\', X_Node_Selector__NUMBER = '+-0123456789'; - + +// XMLWrapper のために今だけ外部に公開 +X_NodeSelector_parse = X_Node_Selector__parse; + /* * セレクタ文字列の解析、但し一挙に行わず、ひと塊づつ * 結合子 + 単体セレクタ( タグ,*,#,.,[],: ) @@ -181,16 +184,22 @@ function X_Node_Selector__parse( query, last ){ break; default : }; + + if( phase === 0xf ) return i; + //alert( chr + ' ' + phase + ' ' + selector + ' ' + name + ' ' + name1st ) if( phase === 0xe ){ if( selector === 4 ){// :not if( name === 'not' ){ - if( not ) return i; // error - not = true; - selector = 0; - phase = 0x0; - name = null; - continue; + if( not ){ + return i; // error + } else { + not = true; + selector = 0; + phase = 0x0; + name = null; + }; + //continue; } else if( name === 'lang' || name === 'contains' ){ result = [ not ? 0 : combinator, selector, name, value ]; @@ -200,16 +209,16 @@ function X_Node_Selector__parse( query, last ){ result = [ not ? 0 : combinator, selector, name, a, b ]; break; }; + } else { + result = + combinator === 5 ? + 5 : + selector === 5 ? + [ not ? 0 : combinator, selector, key, operator, value ] : + [ not ? 0 : combinator, selector, name.split( '\\' ).join( '' ) ]; + break; }; - result = - combinator === 5 ? - 5 : - selector === 5 ? - [ not ? 0 : combinator, selector, key, operator, value ] : - [ not ? 0 : combinator, selector, name.split( '\\' ).join( '' ) ]; - break; - } else - if( phase === 0xf ) return i; + }; escape = chr === '\\' && !escape; }; @@ -311,7 +320,7 @@ function X_Node_Selector__parse( query, last ){ case 2 : for( ; i < l; ++i ){ for( xnode = parents[ i ].firstChild(); xnode; xnode = xnode.nextNode() ){ - if( xnode._xnodeType === 1 && ( isAll || tagName === xnode._tag ) ) xnodes[ ++n ] = xnode; + if( xnode._tag && ( isAll || tagName === xnode._tag ) ) xnodes[ ++n ] = xnode; }; }; break; @@ -319,7 +328,7 @@ function X_Node_Selector__parse( query, last ){ case 3 : for( ; i < l; ++i ){ for( xnode = parents[ i ].nextNode(); xnode; xnode = xnode.nextNode() ){ - if( xnode._xnodeType === 1 ){ + if( xnode._tag ){ if( isAll || tagName === xnode._tag ) xnodes[ ++n ] = xnode; break; }; @@ -331,7 +340,7 @@ function X_Node_Selector__parse( query, last ){ merge = {}; for( ; i < l; ++i ){ for( xnode = parents[ i ].nextNode(); xnode; xnode = xnode.nextNode() ){ - if( xnode._xnodeType === 1 && ( isAll || tagName === xnode._tag ) ){ + if( xnode._tag && ( isAll || tagName === xnode._tag ) ){ uid = xnode._uid; if( merge[ uid ] ){ break; @@ -527,7 +536,7 @@ function X_Node_Selector__parse( query, last ){ j, child, _xnodes; for( ; i < l; ++i ){ child = xnodes[ i ]; - if( child._xnodeType !== 1 ) continue; + if( !child._tag ) continue; //console.log( child._tag ); if( ( j = list.indexOf( child ) ) !== -1 ){ newList[ newList.length ] = child; @@ -552,7 +561,7 @@ function X_Node_Selector__parse( query, last ){ child; for( ; i < l; ++i ){ child = xnodes[ i ]; - if( child._xnodeType === 1 ){ + if( child._tag ){ ( !tag || child._tag === tag ) && ( list[ list.length ] = child ); //console.log( parent._tag + ' > ' + child._tag + ' == ' + tag+ ' l:' + list.length ); child._xnodes && child._xnodes.length && X_Node_Selector__fetchElements( list, child, tag ); @@ -570,7 +579,7 @@ function X_Node_Selector__parse( query, last ){ tmp = null; if( /* tmp === null && */ type <= 0 ){ for( node = xnode.prevNode(); node; node = node.prevNode() ){ - if( node._xnodeType === 1 && ( flag_all || tagName === node._tag ) ){ + if( node._tag && ( flag_all || tagName === node._tag ) ){ tmp = false; break; }; @@ -578,7 +587,7 @@ function X_Node_Selector__parse( query, last ){ }; if( tmp === null && 0 <= type ){ for( node = xnode.nextNode(); node; node = node.nextNode() ){ - if( node._xnodeType === 1 && ( flag_all || tagName === node._tag ) ){ + if( node._tag && ( flag_all || tagName === node._tag ) ){ tmp = false; break; }; @@ -601,7 +610,7 @@ function X_Node_Selector__parse( query, last ){ tmp = checked[ uid ]; if( tmp === void 0 ){ for( c = 0, node = xnode.parent[ pointer ](), tagName = flag_all || xnode._tag; node; node = node[ sibling ]() ){ - if( node._xnodeType === 1 && ( flag_all || tagName === node._tag ) ){ + if( node._tag && ( flag_all || tagName === node._tag ) ){ ++c; checked[ node._uid ] = a === 0 ? c === b : (c - b) % a === 0 && (c - b) / a >= 0; }; @@ -676,7 +685,7 @@ var X_Node_Selector__filter = { for( ; xnode = xnodes[i]; ++i ){ tmp = true; for( node = xnode.firstChild(); node; node = node.nextSibling() ){ - if( node._xnodeType === 1 || ( node._xnodeType === 3 && node._text ) ){ + if( node._tag || ( !node._tag && node._text ) ){ tmp = false; break; };