@@ -5,12 +5,12 @@ const jsDocUrl = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' +
5
5
const jsPrimitiveUrl = 'https://developer.mozilla.org/en-US/docs/Web/' +
6
6
'JavaScript/Data_structures' ;
7
7
const jsPrimitives = {
8
- 'Integer ' : 'Number' , // this is for extending
9
- 'Number ' : 'Number' ,
10
- 'String ' : 'String' ,
11
- 'Boolean ' : 'Boolean' ,
12
- 'Null ' : 'Null' ,
13
- 'Symbol ' : 'Symbol'
8
+ 'integer ' : 'Number' , // this is for extending
9
+ 'number ' : 'Number' ,
10
+ 'string ' : 'String' ,
11
+ 'boolean ' : 'Boolean' ,
12
+ 'null ' : 'Null' ,
13
+ 'symbol ' : 'Symbol'
14
14
} ;
15
15
const jsGlobalTypes = [
16
16
'Error' , 'Object' , 'Function' , 'Array' , 'TypedArray' , 'Uint8Array' ,
@@ -49,7 +49,16 @@ module.exports = {
49
49
typeText = typeText . trim ( ) ;
50
50
if ( typeText ) {
51
51
let typeUrl = null ;
52
- const primitive = jsPrimitives [ typeText ] ;
52
+
53
+ // To support type[], we store the full string and use
54
+ // the bracket-less version to lookup the type URL
55
+ const typeTextFull = typeText ;
56
+ if ( / \[ ] $ / . test ( typeText ) ) {
57
+ typeText = typeText . slice ( 0 , - 2 ) ;
58
+ }
59
+
60
+ const primitive = jsPrimitives [ typeText . toLowerCase ( ) ] ;
61
+
53
62
if ( primitive !== undefined ) {
54
63
typeUrl = `${ jsPrimitiveUrl } #${ primitive } _type` ;
55
64
} else if ( jsGlobalTypes . indexOf ( typeText ) !== - 1 ) {
@@ -60,9 +69,9 @@ module.exports = {
60
69
61
70
if ( typeUrl ) {
62
71
typeLinks . push ( '<a href="' + typeUrl + '" class="type"><' +
63
- typeText + '></a>' ) ;
72
+ typeTextFull + '></a>' ) ;
64
73
} else {
65
- typeLinks . push ( '<span class="type"><' + typeText + '></span>' ) ;
74
+ typeLinks . push ( '<span class="type"><' + typeTextFull + '></span>' ) ;
66
75
}
67
76
}
68
77
} ) ;
0 commit comments