@@ -39,28 +39,32 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
39
39
children . className = "children" ;
40
40
var folders = document . createElement ( "div" ) ;
41
41
folders . className = "folders" ;
42
- for ( var i = 0 ; i < elem . dirs . length ; ++ i ) {
43
- if ( createDirEntry ( elem . dirs [ i ] , folders , fullPath , currentFile ,
44
- hasFoundFile ) === true ) {
45
- addClass ( name , "expand" ) ;
46
- hasFoundFile = true ;
42
+ if ( elem . dirs ) {
43
+ for ( var i = 0 ; i < elem . dirs . length ; ++ i ) {
44
+ if ( createDirEntry ( elem . dirs [ i ] , folders , fullPath , currentFile ,
45
+ hasFoundFile ) === true ) {
46
+ addClass ( name , "expand" ) ;
47
+ hasFoundFile = true ;
48
+ }
47
49
}
48
50
}
49
51
children . appendChild ( folders ) ;
50
52
51
53
var files = document . createElement ( "div" ) ;
52
54
files . className = "files" ;
53
- for ( i = 0 ; i < elem . files . length ; ++ i ) {
54
- var file = document . createElement ( "a" ) ;
55
- file . innerText = elem . files [ i ] ;
56
- file . href = window . rootPath + "src/" + fullPath + elem . files [ i ] + ".html" ;
57
- if ( hasFoundFile === false &&
58
- currentFile === fullPath + elem . files [ i ] ) {
59
- file . className = "selected" ;
60
- addClass ( name , "expand" ) ;
61
- hasFoundFile = true ;
55
+ if ( elem . files ) {
56
+ for ( i = 0 ; i < elem . files . length ; ++ i ) {
57
+ var file = document . createElement ( "a" ) ;
58
+ file . innerText = elem . files [ i ] ;
59
+ file . href = window . rootPath + "src/" + fullPath + elem . files [ i ] + ".html" ;
60
+ if ( hasFoundFile === false &&
61
+ currentFile === fullPath + elem . files [ i ] ) {
62
+ file . className = "selected" ;
63
+ addClass ( name , "expand" ) ;
64
+ hasFoundFile = true ;
65
+ }
66
+ files . appendChild ( file ) ;
62
67
}
63
- files . appendChild ( file ) ;
64
68
}
65
69
search . fullPath = fullPath ;
66
70
children . appendChild ( files ) ;
0 commit comments