1
+ /* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
2
+ /* global onEachLazy, removeClass, searchState, updateLocalStorage */
3
+
1
4
( function ( ) {
2
5
// This mapping table should match the discriminants of
3
6
// `rustdoc::html::item_type::ItemType` type in Rust.
@@ -170,7 +173,7 @@ window.initSearch = function(rawSearchIndex) {
170
173
function sortResults ( results , isType ) {
171
174
var ar = [ ] ;
172
175
for ( var entry in results ) {
173
- if ( hasOwnProperty ( results , entry ) ) {
176
+ if ( hasOwnPropertyRustdoc ( results , entry ) ) {
174
177
ar . push ( results [ entry ] ) ;
175
178
}
176
179
}
@@ -254,7 +257,7 @@ window.initSearch = function(rawSearchIndex) {
254
257
} ) ;
255
258
256
259
for ( i = 0 , len = results . length ; i < len ; ++ i ) {
257
- var result = results [ i ] ;
260
+ result = results [ i ] ;
258
261
259
262
// this validation does not make sense when searching by types
260
263
if ( result . dontValidate ) {
@@ -301,7 +304,7 @@ window.initSearch = function(rawSearchIndex) {
301
304
if ( obj . length > GENERICS_DATA &&
302
305
obj [ GENERICS_DATA ] . length >= val . generics . length ) {
303
306
var elems = Object . create ( null ) ;
304
- var elength = object [ GENERICS_DATA ] . length ;
307
+ var elength = obj [ GENERICS_DATA ] . length ;
305
308
for ( var x = 0 ; x < elength ; ++ x ) {
306
309
elems [ getObjectNameFromId ( obj [ GENERICS_DATA ] [ x ] ) ] += 1 ;
307
310
}
@@ -717,7 +720,7 @@ window.initSearch = function(rawSearchIndex) {
717
720
query . output = val ;
718
721
query . search = val ;
719
722
// gather matching search results up to a certain maximum
720
- val = val . replace ( / \ _/ g, "" ) ;
723
+ val = val . replace ( / _ / g, "" ) ;
721
724
722
725
var valGenerics = extractGenerics ( val ) ;
723
726
@@ -1242,7 +1245,9 @@ window.initSearch = function(rawSearchIndex) {
1242
1245
function getFilterCrates ( ) {
1243
1246
var elem = document . getElementById ( "crate-search" ) ;
1244
1247
1245
- if ( elem && elem . value !== "All crates" && hasOwnProperty ( rawSearchIndex , elem . value ) ) {
1248
+ if ( elem && elem . value !== "All crates" &&
1249
+ hasOwnPropertyRustdoc ( rawSearchIndex , elem . value ) )
1250
+ {
1246
1251
return elem . value ;
1247
1252
}
1248
1253
return undefined ;
@@ -1293,14 +1298,13 @@ window.initSearch = function(rawSearchIndex) {
1293
1298
var id = 0 ;
1294
1299
1295
1300
for ( var crate in rawSearchIndex ) {
1296
- if ( ! hasOwnProperty ( rawSearchIndex , crate ) ) { continue ; }
1301
+ if ( ! hasOwnPropertyRustdoc ( rawSearchIndex , crate ) ) {
1302
+ continue ;
1303
+ }
1297
1304
1298
1305
var crateSize = 0 ;
1299
1306
1300
1307
searchWords . push ( crate ) ;
1301
- var normalizedName = crate . indexOf ( "_" ) === - 1
1302
- ? crate
1303
- : crate . replace ( / _ / g, "" ) ;
1304
1308
// This object should have exactly the same set of fields as the "row"
1305
1309
// object defined below. Your JavaScript runtime will thank you.
1306
1310
// https://mathiasbynens.be/notes/shapes-ics
@@ -1313,7 +1317,7 @@ window.initSearch = function(rawSearchIndex) {
1313
1317
parent : undefined ,
1314
1318
type : null ,
1315
1319
id : id ,
1316
- normalizedName : normalizedName ,
1320
+ normalizedName : crate . indexOf ( "_" ) === - 1 ? crate : crate . replace ( / _ / g , "" ) ,
1317
1321
} ;
1318
1322
id += 1 ;
1319
1323
searchIndex . push ( crateRow ) ;
@@ -1363,9 +1367,6 @@ window.initSearch = function(rawSearchIndex) {
1363
1367
word = "" ;
1364
1368
searchWords . push ( "" ) ;
1365
1369
}
1366
- var normalizedName = word . indexOf ( "_" ) === - 1
1367
- ? word
1368
- : word . replace ( / _ / g, "" ) ;
1369
1370
var row = {
1370
1371
crate : crate ,
1371
1372
ty : itemTypes [ i ] ,
@@ -1375,7 +1376,7 @@ window.initSearch = function(rawSearchIndex) {
1375
1376
parent : itemParentIdxs [ i ] > 0 ? paths [ itemParentIdxs [ i ] - 1 ] : undefined ,
1376
1377
type : itemFunctionSearchTypes [ i ] ,
1377
1378
id : id ,
1378
- normalizedName : normalizedName ,
1379
+ normalizedName : word . indexOf ( "_" ) === - 1 ? word : word . replace ( / _ / g , "" ) ,
1379
1380
} ;
1380
1381
id += 1 ;
1381
1382
searchIndex . push ( row ) ;
@@ -1387,9 +1388,11 @@ window.initSearch = function(rawSearchIndex) {
1387
1388
ALIASES [ crate ] = { } ;
1388
1389
var j , local_aliases ;
1389
1390
for ( var alias_name in aliases ) {
1390
- if ( ! aliases . hasOwnProperty ( alias_name ) ) { continue ; }
1391
+ if ( ! hasOwnPropertyRustdoc ( aliases , alias_name ) ) {
1392
+ continue ;
1393
+ }
1391
1394
1392
- if ( ! ALIASES [ crate ] . hasOwnProperty ( alias_name ) ) {
1395
+ if ( ! hasOwnPropertyRustdoc ( ALIASES [ crate ] , alias_name ) ) {
1393
1396
ALIASES [ crate ] [ alias_name ] = [ ] ;
1394
1397
}
1395
1398
local_aliases = aliases [ alias_name ] ;
0 commit comments