@@ -4,12 +4,12 @@ const jsDocPrefix = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/';
44const jsDocUrl = jsDocPrefix + 'Reference/Global_Objects/' ;
55const jsPrimitiveUrl = jsDocPrefix + 'Data_structures' ;
66const 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'
1313} ;
1414const jsGlobalTypes = [
1515 'Error' , 'Object' , 'Function' , 'Array' , 'TypedArray' , 'Uint8Array' ,
@@ -67,7 +67,16 @@ module.exports = {
6767 typeText = typeText . trim ( ) ;
6868 if ( typeText ) {
6969 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+
7180 if ( primitive !== undefined ) {
7281 typeUrl = `${ jsPrimitiveUrl } #${ primitive } _type` ;
7382 } else if ( jsGlobalTypes . indexOf ( typeText ) !== - 1 ) {
@@ -78,9 +87,9 @@ module.exports = {
7887
7988 if ( typeUrl ) {
8089 typeLinks . push ( '<a href="' + typeUrl + '" class="type"><' +
81- typeText + '></a>' ) ;
90+ typeTextFull + '></a>' ) ;
8291 } else {
83- typeLinks . push ( '<span class="type"><' + typeText + '></span>' ) ;
92+ typeLinks . push ( '<span class="type"><' + typeTextFull + '></span>' ) ;
8493 }
8594 }
8695 } ) ;
0 commit comments