X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F08_XNodeSelector.js;h=1208076d2f473a3ee8cdfc6e4078d32cfb8d733b;hb=5633b955bc9fcd998e8ecf7e8e30c311aafc588c;hp=00b001370b304230b6412eb0f0c0516fc84a43f7;hpb=2956150a7c2798e60639b36d69b0c13f6b20a62a;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 00b0013..1208076 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 @@ -226,13 +227,31 @@ function X_Node_Selector__parse( query, last ){ }; /** - * selector を使って Node を取得する + * selector を使って Node, NodeList を取得する * @alias X.Doc.find * @function * @param {string} セレクター文字列 * @return {Node|NodeList} */ - X[ 'Doc' ][ 'find' ] = X_shortcutFunction = Node.prototype[ 'find' ] = X_NodeList.prototype[ 'find' ] = function ( queryString ){ + X[ 'Doc' ][ 'find' ] = X_shortcutFunction = + + /** + * selector を使って Node, NodeList を取得する + * @alias NodeList.prototype.find + * @function + * @param {string} セレクター文字列 + * @return {Node|NodeList} + */ + X_NodeList.prototype[ 'find' ] = X_Node_find; + + /** + * selector を使って Node, NodeList を取得する + * @alias Node.prototype.find + * @function + * @param {string} セレクター文字列 + * @return {Node|NodeList} + */ + 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 ], parents = scope, // 探索元の親要素 XNodeList の場合あり @@ -262,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 = []; @@ -274,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 []; }; @@ -480,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;