@@ -5,12 +5,12 @@ const jsDocUrl = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' +
55const jsPrimitiveUrl = 'https://developer.mozilla.org/en-US/docs/Web/' +
66 'JavaScript/Data_structures' ;
77const 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'
1414} ;
1515const jsGlobalTypes = [
1616 'Error' , 'Object' , 'Function' , 'Array' , 'TypedArray' , 'Uint8Array' ,
@@ -49,7 +49,16 @@ module.exports = {
4949 typeText = typeText . trim ( ) ;
5050 if ( typeText ) {
5151 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+
5362 if ( primitive !== undefined ) {
5463 typeUrl = `${ jsPrimitiveUrl } #${ primitive } _type` ;
5564 } else if ( jsGlobalTypes . indexOf ( typeText ) !== - 1 ) {
@@ -60,9 +69,9 @@ module.exports = {
6069
6170 if ( typeUrl ) {
6271 typeLinks . push ( '<a href="' + typeUrl + '" class="type"><' +
63- typeText + '></a>' ) ;
72+ typeTextFull + '></a>' ) ;
6473 } else {
65- typeLinks . push ( '<span class="type"><' + typeText + '></span>' ) ;
74+ typeLinks . push ( '<span class="type"><' + typeTextFull + '></span>' ) ;
6675 }
6776 }
6877 } ) ;
0 commit comments