@@ -4,12 +4,12 @@ const jsDocPrefix = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/';
4
4
const jsDocUrl = jsDocPrefix + 'Reference/Global_Objects/' ;
5
5
const jsPrimitiveUrl = jsDocPrefix + 'Data_structures' ;
6
6
const jsPrimitives = {
7
- 'Integer ' : 'Number' , // this is for extending
8
- 'Number ' : 'Number' ,
9
- 'String ' : 'String' ,
10
- 'Boolean ' : 'Boolean' ,
11
- 'Null ' : 'Null' ,
12
- 'Symbol ' : 'Symbol'
7
+ 'integer ' : 'Number' , // this is for extending
8
+ 'number ' : 'Number' ,
9
+ 'string ' : 'String' ,
10
+ 'boolean ' : 'Boolean' ,
11
+ 'null ' : 'Null' ,
12
+ 'symbol ' : 'Symbol'
13
13
} ;
14
14
const jsGlobalTypes = [
15
15
'Error' , 'Object' , 'Function' , 'Array' , 'TypedArray' , 'Uint8Array' ,
@@ -67,7 +67,16 @@ module.exports = {
67
67
typeText = typeText . trim ( ) ;
68
68
if ( typeText ) {
69
69
let typeUrl = null ;
70
- const primitive = jsPrimitives [ typeText ] ;
70
+
71
+ // To support type[], we store the full string and use
72
+ // the bracket-less version to lookup the type URL
73
+ const typeTextFull = typeText ;
74
+ if ( / \[ ] $ / . test ( typeText ) ) {
75
+ typeText = typeText . slice ( 0 , - 2 ) ;
76
+ }
77
+
78
+ const primitive = jsPrimitives [ typeText . toLowerCase ( ) ] ;
79
+
71
80
if ( primitive !== undefined ) {
72
81
typeUrl = `${ jsPrimitiveUrl } #${ primitive } _type` ;
73
82
} else if ( jsGlobalTypes . indexOf ( typeText ) !== - 1 ) {
@@ -78,9 +87,9 @@ module.exports = {
78
87
79
88
if ( typeUrl ) {
80
89
typeLinks . push ( '<a href="' + typeUrl + '" class="type"><' +
81
- typeText + '></a>' ) ;
90
+ typeTextFull + '></a>' ) ;
82
91
} else {
83
- typeLinks . push ( '<span class="type"><' + typeText + '></span>' ) ;
92
+ typeLinks . push ( '<span class="type"><' + typeTextFull + '></span>' ) ;
84
93
}
85
94
}
86
95
} ) ;
0 commit comments