1+ /* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
2+ /* global onEachLazy, removeClass, searchState, updateLocalStorage */
3+
14( function ( ) {
25// This mapping table should match the discriminants of
36// `rustdoc::html::item_type::ItemType` type in Rust.
@@ -170,7 +173,7 @@ window.initSearch = function(rawSearchIndex) {
170173 function sortResults ( results , isType ) {
171174 var ar = [ ] ;
172175 for ( var entry in results ) {
173- if ( hasOwnProperty ( results , entry ) ) {
176+ if ( hasOwnPropertyRustdoc ( results , entry ) ) {
174177 ar . push ( results [ entry ] ) ;
175178 }
176179 }
@@ -254,7 +257,7 @@ window.initSearch = function(rawSearchIndex) {
254257 } ) ;
255258
256259 for ( i = 0 , len = results . length ; i < len ; ++ i ) {
257- var result = results [ i ] ;
260+ result = results [ i ] ;
258261
259262 // this validation does not make sense when searching by types
260263 if ( result . dontValidate ) {
@@ -301,7 +304,7 @@ window.initSearch = function(rawSearchIndex) {
301304 if ( obj . length > GENERICS_DATA &&
302305 obj [ GENERICS_DATA ] . length >= val . generics . length ) {
303306 var elems = Object . create ( null ) ;
304- var elength = object [ GENERICS_DATA ] . length ;
307+ var elength = obj [ GENERICS_DATA ] . length ;
305308 for ( var x = 0 ; x < elength ; ++ x ) {
306309 elems [ getObjectNameFromId ( obj [ GENERICS_DATA ] [ x ] ) ] += 1 ;
307310 }
@@ -717,7 +720,7 @@ window.initSearch = function(rawSearchIndex) {
717720 query . output = val ;
718721 query . search = val ;
719722 // gather matching search results up to a certain maximum
720- val = val . replace ( / \ _/ g, "" ) ;
723+ val = val . replace ( / _ / g, "" ) ;
721724
722725 var valGenerics = extractGenerics ( val ) ;
723726
@@ -1242,7 +1245,9 @@ window.initSearch = function(rawSearchIndex) {
12421245 function getFilterCrates ( ) {
12431246 var elem = document . getElementById ( "crate-search" ) ;
12441247
1245- if ( elem && elem . value !== "All crates" && hasOwnProperty ( rawSearchIndex , elem . value ) ) {
1248+ if ( elem && elem . value !== "All crates" &&
1249+ hasOwnPropertyRustdoc ( rawSearchIndex , elem . value ) )
1250+ {
12461251 return elem . value ;
12471252 }
12481253 return undefined ;
@@ -1293,14 +1298,13 @@ window.initSearch = function(rawSearchIndex) {
12931298 var id = 0 ;
12941299
12951300 for ( var crate in rawSearchIndex ) {
1296- if ( ! hasOwnProperty ( rawSearchIndex , crate ) ) { continue ; }
1301+ if ( ! hasOwnPropertyRustdoc ( rawSearchIndex , crate ) ) {
1302+ continue ;
1303+ }
12971304
12981305 var crateSize = 0 ;
12991306
13001307 searchWords . push ( crate ) ;
1301- var normalizedName = crate . indexOf ( "_" ) === - 1
1302- ? crate
1303- : crate . replace ( / _ / g, "" ) ;
13041308 // This object should have exactly the same set of fields as the "row"
13051309 // object defined below. Your JavaScript runtime will thank you.
13061310 // https://mathiasbynens.be/notes/shapes-ics
@@ -1313,7 +1317,7 @@ window.initSearch = function(rawSearchIndex) {
13131317 parent : undefined ,
13141318 type : null ,
13151319 id : id ,
1316- normalizedName : normalizedName ,
1320+ normalizedName : crate . indexOf ( "_" ) === - 1 ? crate : crate . replace ( / _ / g , "" ) ,
13171321 } ;
13181322 id += 1 ;
13191323 searchIndex . push ( crateRow ) ;
@@ -1363,9 +1367,6 @@ window.initSearch = function(rawSearchIndex) {
13631367 word = "" ;
13641368 searchWords . push ( "" ) ;
13651369 }
1366- var normalizedName = word . indexOf ( "_" ) === - 1
1367- ? word
1368- : word . replace ( / _ / g, "" ) ;
13691370 var row = {
13701371 crate : crate ,
13711372 ty : itemTypes [ i ] ,
@@ -1375,7 +1376,7 @@ window.initSearch = function(rawSearchIndex) {
13751376 parent : itemParentIdxs [ i ] > 0 ? paths [ itemParentIdxs [ i ] - 1 ] : undefined ,
13761377 type : itemFunctionSearchTypes [ i ] ,
13771378 id : id ,
1378- normalizedName : normalizedName ,
1379+ normalizedName : word . indexOf ( "_" ) === - 1 ? word : word . replace ( / _ / g , "" ) ,
13791380 } ;
13801381 id += 1 ;
13811382 searchIndex . push ( row ) ;
@@ -1387,9 +1388,11 @@ window.initSearch = function(rawSearchIndex) {
13871388 ALIASES [ crate ] = { } ;
13881389 var j , local_aliases ;
13891390 for ( var alias_name in aliases ) {
1390- if ( ! aliases . hasOwnProperty ( alias_name ) ) { continue ; }
1391+ if ( ! hasOwnPropertyRustdoc ( aliases , alias_name ) ) {
1392+ continue ;
1393+ }
13911394
1392- if ( ! ALIASES [ crate ] . hasOwnProperty ( alias_name ) ) {
1395+ if ( ! hasOwnPropertyRustdoc ( ALIASES [ crate ] , alias_name ) ) {
13931396 ALIASES [ crate ] [ alias_name ] = [ ] ;
13941397 }
13951398 local_aliases = aliases [ alias_name ] ;
0 commit comments