hidglobal / digitalpersona-devices

DigitalPersona Security Devices support library
https://hidglobal.github.io/digitalpersona-devices/index.html
MIT License
64 stars 41 forks source link

Uncaught ReferenceError: assignment to undeclared variable i #26

Closed isfan14 closed 8 months ago

isfan14 commented 2 years ago

https://github.com/hidglobal/digitalpersona-devices/blob/fcbeaaddca28d6651a2c12b6656af9c8860de925/%40types/WebSdk/index.js#L4677-L4678

I got this error when trying to use it in my Nuxt3 project. I think those lines need var declaration

a-bronx commented 2 years ago

Thank you, I'll pass the issue to the developer of the WebSdk dependency and update the sample,

locent217 commented 8 months ago

I have the same issue and I can't use it on my vue app image

a-bronx commented 8 months ago

Please try the updated WebSdk module from here, this should solve the issue with a local var declaration.

locent217 commented 8 months ago

@a-bronx I copied the index.js code from the link you provided, and still the i = 0; does not have var declaration. so i just manually updated on my local file. thank you!

a-bronx commented 8 months ago

@locant271 can you tell the line number where the i = 0; without var happens?

locent217 commented 8 months ago

@a-bronx There's a lot of it. I Just searched all lines with "(i = 0" and changed it to (var i = 0

a-bronx commented 8 months ago

@locent217 But which of them causes an issue? Every remaining instance follow a common (and benign) pattern:

function foo() {
    var i;                          // << creates a variable in a function-level scope
    ...
    for(i = 0; ,,,) {}            // << uses the local variable
}

Unlike the initial report, this pattern should not cause any issues as each var creates a function-level scope and do not mess with globals. So there is no real need "fix" what is not broken.

locent217 commented 8 months ago

@a-bronx Hello! From the lines 1303, 1318, and 1329. Can you check if it does cause the error?

locent217 commented 8 months ago

@a-bronx my bad, I just realize that the link provided from the tutorial leads to another branch, not the master branch, that is why I am getting the error. I fixed it now by copying the code from master branch. thanks!

a-bronx commented 8 months ago

@locent217 Oh, good catch, thank you! I fixed links.