OSDN Git Service

Fix the bug of X.NodeAnime.
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 08_XNodeSelector.js
index 00b0013..0868315 100644 (file)
@@ -78,10 +78,11 @@ function X_Node_Selector__parse( query, last ){
                chr, chrCode, nameChr, name1st,\r
                tmp, escape, quot, start,\r
                name, key, value, operator, a, b, not;\r
+\r
        query += ' ';\r
        while( i < l ){\r
                chr     = query.charAt( ++i );\r
-               chrCode = ALPHABET.indexOf( chr );\r
+               chrCode = ALPHABET.indexOf( chr ); // TODO この関数無くす!\r
                nameChr = chrCode !== -1;\r
                name1st = nameChr && chrCode < 52;\r
                switch( phase ){\r
@@ -195,7 +196,7 @@ function X_Node_Selector__parse( query, last ){
                                                not      = true;\r
                                                selector = 0;\r
                                                phase    = 0x0;\r
-                                               name     = null;                                        \r
+                                               name     = null;\r
                                        };\r
                                        //continue;\r
                                } else\r
@@ -226,15 +227,33 @@ function X_Node_Selector__parse( query, last ){
 };\r
 \r
        /**\r
-        * selector を使って Node を取得する\r
+        * selector を使って Node, NodeList を取得する\r
         * @alias X.Doc.find\r
         * @function\r
         * @param {string} セレクター文字列\r
         * @return {Node|NodeList}\r
         */\r
-       X[ 'Doc' ][ 'find' ] = X_shortcutFunction = Node.prototype[ 'find' ] = X_NodeList.prototype[ 'find' ] = function ( queryString ){\r
+       X[ 'Doc' ][ 'find' ] = X_shortcutFunction =\r
+\r
+       /**\r
+        * selector を使って Node, NodeList を取得する\r
+        * @alias NodeList.prototype.find\r
+        * @function\r
+        * @param {string} セレクター文字列\r
+        * @return {Node|NodeList}\r
+        */\r
+       X_NodeList.prototype[ 'find' ] = X_Node_find;\r
+       \r
+       /**\r
+        * selector を使って Node, NodeList を取得する\r
+        * @alias Node.prototype.find\r
+        * @function\r
+        * @param {string} セレクター文字列\r
+        * @return {Node|NodeList}\r
+        */     \r
+       function X_Node_find( queryString ){\r
                var HTML      = X_Node_html,\r
-                       scope     = this.constructor === X_NodeList && this.length ? this : [ this.constructor === Node ? this : X_Node_body ],\r
+                       scope     = this.constructor === X_NodeList && this.length ? this : [ this.constructor === Node || this[ 'instanceOf' ] && this[ 'instanceOf' ]( Node ) ? this : X_Node_body ],\r
                        parents   = scope, // 探索元の親要素 XNodeList の場合あり\r
                        // TODO { title : true,,, }\r
                        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( ' ' ),\r
@@ -262,7 +281,7 @@ function X_Node_Selector__parse( query, last ){
                /*]@+debug*/\r
 \r
                // 文字列以外は空で返す\r
-               if( typeof queryString !== 'string' ) return ret;\r
+               if( !X_Type_isString( queryString ) ) return ret;\r
                \r
                xnodes = [];\r
                \r
@@ -274,7 +293,7 @@ function X_Node_Selector__parse( query, last ){
                        if( !parsed ){\r
                                parsed = X_Node_Selector__parse( queryString );\r
                                \r
-                               if( typeof parsed === 'number' ){\r
+                               if( X_Type_isNumber( parsed ) ){\r
                                        // error\r
                                        return [];\r
                                };\r
@@ -480,7 +499,7 @@ function X_Node_Selector__parse( query, last ){
                                        );\r
                                } else\r
                                // filterが関数の場合\r
-                               if( typeof filter === 'function' ){\r
+                               if( X_Type_isFunction( filter ) ){\r
                                        tmp = [];\r
                                        for( i = 0, n = -1; xnode = xnodes[ i ]; ++i ){\r
                                                if( ( !!filter( xnode ) ) ^ isNot ) tmp[ ++n ] = xnode; \r
@@ -592,6 +611,7 @@ function X_Node_Selector__parse( query, last ){
                var l = xnodes.length,\r
                        i = 0,\r
                        j, child, _xnodes;\r
+\r
                for( ; i < l; ++i ){\r
                        child = xnodes[ i ];\r
                        if( !child[ '_tag' ] ) continue;\r
@@ -616,7 +636,8 @@ function X_Node_Selector__parse( query, last ){
                var l      = xnodes.length,\r
                        i      = 0,\r
                        child, uid, _tag, _xnodes;\r
-               for( ; i < l; ++i ){\r
+\r
+               for( ; i < l; ++i ){ // for( ; child = xnodes[ ++i ]; )\r
                        child = xnodes[ i ];\r
                        uid   = child[ '_uid' ];\r
                        _tag  = child[ '_tag' ];\r