@@ -3097,12 +3097,12 @@ function initSearch(rawSearchIndex) {
30973097 const longType = longItemTypes [ item . ty ] ;
30983098 const typeName = longType . length !== 0 ? `${ longType } ` : "?" ;
30993099
3100- const li = document . createElement ( "li " ) ;
3100+ const li = document . createElement ( "a " ) ;
31013101 li . className = "result-" + type ;
3102+ li . href = item . href ;
31023103
3103- const resultName = document . createElement ( "a " ) ;
3104+ const resultName = document . createElement ( "span " ) ;
31043105 resultName . className = "result-name" ;
3105- resultName . href = item . href ;
31063106
31073107 resultName . insertAdjacentHTML (
31083108 "beforeend" ,
@@ -3126,29 +3126,46 @@ ${item.displayPath}<span class="${type}">${name}</span>\
31263126 if ( item . displayTypeSignature ) {
31273127 const { type, mappedNames, whereClause} = await item . displayTypeSignature ;
31283128 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+ } ) ;
31293138 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+ } ;
31343146 for ( const [ name , qname ] of mappedNames ) {
31353147 // don't care unless the generic name is different
31363148 if ( name === qname ) {
31373149 continue ;
31383150 }
3151+ addWhereLineFn ( ) ;
31393152 const line = document . createElement ( "div" ) ;
31403153 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 ) ;
31433159 }
31443160 for ( const [ name , innerType ] of whereClause ) {
31453161 // don't care unless there's at least one highlighted entry
31463162 if ( innerType . length <= 1 ) {
31473163 continue ;
31483164 }
3165+ addWhereLineFn ( ) ;
31493166 const line = document . createElement ( "div" ) ;
31503167 line . className = "where" ;
3151- line . appendChild ( document . createTextNode ( `${ name } : ` ) ) ;
3168+ line . appendChild ( document . createTextNode ( ` ${ name } : ` ) ) ;
31523169 innerType . forEach ( ( value , index ) => {
31533170 if ( index % 2 !== 0 ) {
31543171 const highlight = document . createElement ( "strong" ) ;
@@ -3158,55 +3175,15 @@ ${item.displayPath}<span class="${type}">${name}</span>\
31583175 line . appendChild ( document . createTextNode ( value ) ) ;
31593176 }
31603177 } ) ;
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 ) ;
31783179 }
31793180 }
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- } ) ;
31893181 displayType . className = "type-signature" ;
3190- description . appendChild ( displayType ) ;
3182+ li . appendChild ( displayType ) ;
31913183 }
31923184 description . insertAdjacentHTML ( "beforeend" , item . desc ) ;
31933185
31943186 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- } ;
32103187 return li ;
32113188 } ) ) ;
32123189 lis . then ( lis => {
@@ -4293,17 +4270,17 @@ ${item.displayPath}<span class="${type}">${name}</span>\
42934270 // up and down arrow select next/previous search result, or the
42944271 // search box if we're already at the top.
42954272 if ( e . which === 38 ) { // up
4296- const previous = document . activeElement . parentNode . previousElementSibling ;
4273+ const previous = document . activeElement . previousElementSibling ;
42974274 if ( previous ) {
4298- previous . querySelectorAll ( "a" ) . item ( 0 ) . focus ( ) ;
4275+ previous . focus ( ) ;
42994276 } else {
43004277 searchState . focus ( ) ;
43014278 }
43024279 e . preventDefault ( ) ;
43034280 } else if ( e . which === 40 ) { // down
4304- const next = document . activeElement . parentNode . nextElementSibling ;
4281+ const next = document . activeElement . nextElementSibling ;
43054282 if ( next ) {
4306- next . querySelectorAll ( "a" ) . item ( 0 ) . focus ( ) ;
4283+ next . focus ( ) ;
43074284 }
43084285 const rect = document . activeElement . getBoundingClientRect ( ) ;
43094286 if ( window . innerHeight - rect . bottom < rect . height ) {
0 commit comments