_handleArrowSelect function - uncaught reference (i) in for loop
See original GitHub issueWhen I do any search and try to use the arrow key to navigate the results i receive a reference exception:
Uncaught ReferenceError: i is not defined
This is triggered by the for loop on line 828 in leaflet-search.src.js. i is an implicit global variable and in strict mode this will kick up an error:
for (i=0; i<searchTips.length; i++)
If you declare i then it fixes the error. It becomes a local variable i.e:
for (let i=0; i<searchTips.length; i++)
Can this be updated in the package?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
javascript - How to fix "Uncaught ReferenceError" in a for..in loop
Normally, it would just iterate over the loop, but now it's throwing an error. Any help would be greatly appreciated! javascript · arrays ......
Read more >For loop ReferenceError: 'i' is not defined in JS | bobbyhadz
The "ReferenceError i is not defined" error occurs when we forget to use the `let` statement to define the index variable in a...
Read more >How to Resolve an Uncaught Reference Error in Javascript
The ReferenceError occurs when referencing a variable that does not exist or has not been initialized in the current scope.
Read more >each() Uncaught ReferenceError: i is not defined - Treehouse
I'm getting a reference error. I'm retrieving json data via ajax. I'm able to post all the data to my console so I...
Read more >ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
Variables defined inside a function cannot be accessed from anywhere outside the function, because the variable is defined only in the scope of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Dude, just updated to the 3.0.1 version and double checked the GitHub code, the line
for (i=0; i<searchTips.length; i++)
is still there, if you replace it withfor (let i=0; i<searchTips.length; i++)
as @Robc24 mentioned, the up/down arrow key function works again.https://www.npmjs.com/package/leaflet-search/v/3.0.0
https://github.com/stefanocudini/leaflet-search/commits/v3.0.0