@@ -3097,12 +3097,12 @@ function initSearch(rawSearchIndex) {
3097
3097
const longType = longItemTypes [ item . ty ] ;
3098
3098
const typeName = longType . length !== 0 ? `${ longType } ` : "?" ;
3099
3099
3100
- const li = document . createElement ( "li " ) ;
3100
+ const li = document . createElement ( "a " ) ;
3101
3101
li . className = "result-" + type ;
3102
+ li . href = item . href ;
3102
3103
3103
- const resultName = document . createElement ( "a " ) ;
3104
+ const resultName = document . createElement ( "span " ) ;
3104
3105
resultName . className = "result-name" ;
3105
- resultName . href = item . href ;
3106
3106
3107
3107
resultName . insertAdjacentHTML (
3108
3108
"beforeend" ,
@@ -3126,29 +3126,46 @@ ${item.displayPath}<span class="${type}">${name}</span>\
3126
3126
if ( item . displayTypeSignature ) {
3127
3127
const { type, mappedNames, whereClause} = await item . displayTypeSignature ;
3128
3128
const displayType = document . createElement ( "div" ) ;
3129
+ type . forEach ( ( value , index ) => {
3130
+ if ( index % 2 !== 0 ) {
3131
+ const highlight = document . createElement ( "strong" ) ;
3132
+ highlight . appendChild ( document . createTextNode ( value ) ) ;
3133
+ displayType . appendChild ( highlight ) ;
3134
+ } else {
3135
+ displayType . appendChild ( document . createTextNode ( value ) ) ;
3136
+ }
3137
+ } ) ;
3129
3138
if ( mappedNames . size > 0 || whereClause . size > 0 ) {
3130
- const tooltip = document . createElement ( "a" ) ;
3131
- tooltip . id = `tooltip-${ item . id } ` ;
3132
- tooltip . href = `#${ tooltip . id } ` ;
3133
- const tooltipCode = document . createElement ( "code" ) ;
3139
+ let addWhereLineFn = ( ) => {
3140
+ const line = document . createElement ( "div" ) ;
3141
+ line . className = "where" ;
3142
+ line . appendChild ( document . createTextNode ( "where" ) ) ;
3143
+ displayType . appendChild ( line ) ;
3144
+ addWhereLineFn = ( ) => { } ;
3145
+ } ;
3134
3146
for ( const [ name , qname ] of mappedNames ) {
3135
3147
// don't care unless the generic name is different
3136
3148
if ( name === qname ) {
3137
3149
continue ;
3138
3150
}
3151
+ addWhereLineFn ( ) ;
3139
3152
const line = document . createElement ( "div" ) ;
3140
3153
line . className = "where" ;
3141
- line . appendChild ( document . createTextNode ( `${ name } is ${ qname } ` ) ) ;
3142
- tooltipCode . appendChild ( line ) ;
3154
+ line . appendChild ( document . createTextNode ( ` ${ qname } matches ` ) ) ;
3155
+ const lineStrong = document . createElement ( "strong" ) ;
3156
+ lineStrong . appendChild ( document . createTextNode ( name ) ) ;
3157
+ line . appendChild ( lineStrong ) ;
3158
+ displayType . appendChild ( line ) ;
3143
3159
}
3144
3160
for ( const [ name , innerType ] of whereClause ) {
3145
3161
// don't care unless there's at least one highlighted entry
3146
3162
if ( innerType . length <= 1 ) {
3147
3163
continue ;
3148
3164
}
3165
+ addWhereLineFn ( ) ;
3149
3166
const line = document . createElement ( "div" ) ;
3150
3167
line . className = "where" ;
3151
- line . appendChild ( document . createTextNode ( `${ name } : ` ) ) ;
3168
+ line . appendChild ( document . createTextNode ( ` ${ name } : ` ) ) ;
3152
3169
innerType . forEach ( ( value , index ) => {
3153
3170
if ( index % 2 !== 0 ) {
3154
3171
const highlight = document . createElement ( "strong" ) ;
@@ -3158,55 +3175,15 @@ ${item.displayPath}<span class="${type}">${name}</span>\
3158
3175
line . appendChild ( document . createTextNode ( value ) ) ;
3159
3176
}
3160
3177
} ) ;
3161
- tooltipCode . appendChild ( line ) ;
3162
- }
3163
- if ( tooltipCode . childNodes . length !== 0 ) {
3164
- tooltip . RUSTDOC_TOOLTIP_DOM = document . createElement ( "div" ) ;
3165
- tooltip . RUSTDOC_TOOLTIP_DOM . className = "content" ;
3166
- const tooltipH3 = document . createElement ( "h3" ) ;
3167
- tooltipH3 . innerHTML = "About this result" ;
3168
- tooltip . RUSTDOC_TOOLTIP_DOM . appendChild ( tooltipH3 ) ;
3169
- const tooltipPre = document . createElement ( "pre" ) ;
3170
- tooltipPre . appendChild ( tooltipCode ) ;
3171
- tooltip . RUSTDOC_TOOLTIP_DOM . appendChild ( tooltipPre ) ;
3172
- tooltip . typeWhereClause = whereClause ;
3173
- tooltip . innerText = "ⓘ" ;
3174
- tooltip . className = "tooltip" ;
3175
- window . rustdocConfigureTooltip ( tooltip ) ;
3176
- displayType . appendChild ( tooltip ) ;
3177
- displayType . appendChild ( document . createTextNode ( " " ) ) ;
3178
+ displayType . appendChild ( line ) ;
3178
3179
}
3179
3180
}
3180
- type . forEach ( ( value , index ) => {
3181
- if ( index % 2 !== 0 ) {
3182
- const highlight = document . createElement ( "strong" ) ;
3183
- highlight . appendChild ( document . createTextNode ( value ) ) ;
3184
- displayType . appendChild ( highlight ) ;
3185
- } else {
3186
- displayType . appendChild ( document . createTextNode ( value ) ) ;
3187
- }
3188
- } ) ;
3189
3181
displayType . className = "type-signature" ;
3190
- description . appendChild ( displayType ) ;
3182
+ li . appendChild ( displayType ) ;
3191
3183
}
3192
3184
description . insertAdjacentHTML ( "beforeend" , item . desc ) ;
3193
3185
3194
3186
li . appendChild ( description ) ;
3195
- li . tabIndex = - 1 ;
3196
- li . onclick = ( ) => {
3197
- // allow user to select the description text without navigating
3198
- // also, they can select the path itself by starting the selection here
3199
- // (a UI feature I got used to from DuckDuckGo)
3200
- if ( window . getSelection ) {
3201
- const selection = window . getSelection ( ) ;
3202
- if ( selection && ! selection . isCollapsed ) {
3203
- return ;
3204
- }
3205
- }
3206
- // allow clicking anywhere on the list item to go to the page
3207
- // even though the link itself is only the name
3208
- resultName . click ( ) ;
3209
- } ;
3210
3187
return li ;
3211
3188
} ) ) ;
3212
3189
lis . then ( lis => {
@@ -4293,17 +4270,17 @@ ${item.displayPath}<span class="${type}">${name}</span>\
4293
4270
// up and down arrow select next/previous search result, or the
4294
4271
// search box if we're already at the top.
4295
4272
if ( e . which === 38 ) { // up
4296
- const previous = document . activeElement . parentNode . previousElementSibling ;
4273
+ const previous = document . activeElement . previousElementSibling ;
4297
4274
if ( previous ) {
4298
- previous . querySelectorAll ( "a" ) . item ( 0 ) . focus ( ) ;
4275
+ previous . focus ( ) ;
4299
4276
} else {
4300
4277
searchState . focus ( ) ;
4301
4278
}
4302
4279
e . preventDefault ( ) ;
4303
4280
} else if ( e . which === 40 ) { // down
4304
- const next = document . activeElement . parentNode . nextElementSibling ;
4281
+ const next = document . activeElement . nextElementSibling ;
4305
4282
if ( next ) {
4306
- next . querySelectorAll ( "a" ) . item ( 0 ) . focus ( ) ;
4283
+ next . focus ( ) ;
4307
4284
}
4308
4285
const rect = document . activeElement . getBoundingClientRect ( ) ;
4309
4286
if ( window . innerHeight - rect . bottom < rect . height ) {
0 commit comments