@@ -2564,8 +2564,15 @@ function module_code(library_namespace) {
25642564
25652565 library_namespace . debug ( 'Get [' + selector + ']' , 2 , 'select_node' ) ;
25662566 if ( library_namespace . is_Object ( base_space ) ) {
2567+ if ( ! options ) {
2568+ options = base_space ;
2569+ }
25672570 base_space = base_space . base ;
2571+ } else if ( ! options ) {
2572+ options = library_namespace . setup_options ( options ) ;
25682573 }
2574+ if ( ! base_space )
2575+ base_space = options . base ;
25692576
25702577 try {
25712578 if ( typeof base_space === 'string' && base_space ) {
@@ -2584,7 +2591,7 @@ function module_code(library_namespace) {
25842591
25852592 // http://inspire.twgg.org/programming/javascript/item/383-more-efficient-than-the-native-jquery-dom-selector-queryselector-and-queryselectorall.html
25862593 var result ;
2587- if ( base_space . querySelectorAll )
2594+ if ( base_space . querySelectorAll ) {
25882595 try {
25892596 library_namespace . debug (
25902597 'using native .querySelectorAll() to select ['
@@ -2594,15 +2601,17 @@ function module_code(library_namespace) {
25942601 result = base_space . querySelectorAll (
25952602 // 處理本函數特有之**非標準**功能。尚有問題!
25962603 selector . replace ( / \$ ( [ _ a - z ] [ _ a - z \d ] * ) / gi, '[name="$1"]' ) ) ;
2597- if ( result . length > 0 )
2604+ if ( result . length > 0 ) {
25982605 return result . length > 1 ? result : result [ 0 ] ;
2606+ }
25992607 library_namespace . debug ( 'Nothing got. 嘗試本 library 傳統方法。' ,
26002608 2 , 'select_node' ) ;
26012609 } catch ( e ) {
26022610 library_namespace . debug (
26032611 '可能有不支援的 selector。改回本 library 傳統方法。' , 2 ,
26042612 'select_node' ) ;
26052613 }
2614+ }
26062615
26072616 result = base_space ;
26082617 var tmp_node , tag_name , identifier , part ,
@@ -2816,7 +2825,7 @@ function module_code(library_namespace) {
28162825 : select_node ( '*' ) ;
28172826 } else if ( typeof nodes === 'string' ) {
28182827 // selector || id
2819- nodes = select_node ( nodes ) || get_element ( nodes ) ;
2828+ nodes = select_node ( nodes , options ) || get_element ( nodes ) ;
28202829 }
28212830
28222831 if ( _ . is_ELEMENT_NODE ( nodes ) || _ . is_DOCUMENT_NODE ( nodes ) ) {
90209029
90219030 /** {Integer}to <h\d>. default: 6. */
90229031 var level = options . level ;
9023- // h1-3 : 為最常利用之中級結構。
9024- length = level >= 1 && level <= 6 ? level | 0 : 3 ;
9032+ // <h1>-<h6>. or till <h3> : 為最常利用之中級結構。
9033+ length = level >= 1 && level <= 6 ? level | 0 : 6 ;
90259034 level = [ 'header' ] ;
90269035 for ( index = 0 ; index < length ; ) {
90279036 level . push ( 'h' + ++ index ) ;
90749083 } ) ;
90759084 }
90769085
9077- for_nodes ( add_TOC_node , level ) ;
9086+ for_nodes ( add_TOC_node , level , {
9087+ base : content_node
9088+ } ) ;
90789089
90799090 if ( list_array . length === 0 ) {
90809091 library_namespace . warn ( 'auto_TOC: No ' + level + ' found.' ) ;
0 commit comments