X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F08_XNodeSelector.js;h=0868315520f9a1394fe663a7f4ce34ceb51b1560;hb=ef25747bebf1799d49f9bd0d64e339da9ea61d13;hp=4b735e0e6c245607c8dff1014e0ebaeb45f5fbe5;hpb=8e63f506d14490e852fa557d326ca91f9cdd3baf;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 4b735e0..0868315 100644 --- a/0.6.x/js/02_dom/08_XNodeSelector.js +++ b/0.6.x/js/02_dom/08_XNodeSelector.js @@ -78,10 +78,11 @@ function X_Node_Selector__parse( query, last ){ chr, chrCode, nameChr, name1st, tmp, escape, quot, start, name, key, value, operator, a, b, not; + query += ' '; while( i < l ){ chr = query.charAt( ++i ); - chrCode = ALPHABET.indexOf( chr ); + chrCode = ALPHABET.indexOf( chr ); // TODO この関数無くす! nameChr = chrCode !== -1; name1st = nameChr && chrCode < 52; switch( phase ){ @@ -195,7 +196,7 @@ function X_Node_Selector__parse( query, last ){ not = true; selector = 0; phase = 0x0; - name = null; + name = null; }; //continue; } else @@ -233,24 +234,26 @@ function X_Node_Selector__parse( query, last ){ * @return {Node|NodeList} */ X[ 'Doc' ][ 'find' ] = X_shortcutFunction = + /** * selector を使って Node, NodeList を取得する - * @alias Node.prototype.find + * @alias NodeList.prototype.find * @function * @param {string} セレクター文字列 * @return {Node|NodeList} */ - Node.prototype[ 'find' ] = + X_NodeList.prototype[ 'find' ] = X_Node_find; + /** * selector を使って Node, NodeList を取得する - * @alias NodeList.prototype.find + * @alias Node.prototype.find * @function * @param {string} セレクター文字列 * @return {Node|NodeList} - */ - X_NodeList.prototype[ 'find' ] = function ( queryString ){ + */ + function X_Node_find( queryString ){ var HTML = X_Node_html, - scope = this.constructor === X_NodeList && this.length ? this : [ this.constructor === Node ? this : X_Node_body ], + scope = this.constructor === X_NodeList && this.length ? this : [ this.constructor === Node || this[ 'instanceOf' ] && this[ 'instanceOf' ]( Node ) ? this : X_Node_body ], parents = scope, // 探索元の親要素 XNodeList の場合あり // TODO { title : true,,, } noLower = 'title id name class for action archive background cite classid codebase data href longdesc profile src usemap',// + X_Dom_DTD_ATTR_VAL_IS_URI.join( ' ' ), @@ -278,7 +281,7 @@ function X_Node_Selector__parse( query, last ){ /*]@+debug*/ // 文字列以外は空で返す - if( typeof queryString !== 'string' ) return ret; + if( !X_Type_isString( queryString ) ) return ret; xnodes = []; @@ -290,7 +293,7 @@ function X_Node_Selector__parse( query, last ){ if( !parsed ){ parsed = X_Node_Selector__parse( queryString ); - if( typeof parsed === 'number' ){ + if( X_Type_isNumber( parsed ) ){ // error return []; }; @@ -496,7 +499,7 @@ function X_Node_Selector__parse( query, last ){ ); } else // filterが関数の場合 - if( typeof filter === 'function' ){ + if( X_Type_isFunction( filter ) ){ tmp = []; for( i = 0, n = -1; xnode = xnodes[ i ]; ++i ){ if( ( !!filter( xnode ) ) ^ isNot ) tmp[ ++n ] = xnode; @@ -608,6 +611,7 @@ function X_Node_Selector__parse( query, last ){ var l = xnodes.length, i = 0, j, child, _xnodes; + for( ; i < l; ++i ){ child = xnodes[ i ]; if( !child[ '_tag' ] ) continue; @@ -632,7 +636,8 @@ function X_Node_Selector__parse( query, last ){ var l = xnodes.length, i = 0, child, uid, _tag, _xnodes; - for( ; i < l; ++i ){ + + for( ; i < l; ++i ){ // for( ; child = xnodes[ ++i ]; ) child = xnodes[ i ]; uid = child[ '_uid' ]; _tag = child[ '_tag' ];