reymond-group/smilesDrawer

TypeError: weights.every is not a function

Opened this issue · 4 comments

njzjz commented

After the version was bumped from v2.0.3 to v2.1.2, I got the following error:

TypeError: weights.every is not a function
    at module.exports.drawWeights (smiles-drawer.min.js:56:216581)
    at module.exports.draw (smiles-drawer.min.js:56:208856)
    at bundle.js:2:12354
    at SmilesDrawer.parse (smiles-drawer.min.js:1:1751)
    at f (bundle.js:2:12331)
    at HTMLDivElement.<anonymous> (bundle.js:2:9746)
    at Function.each (jquery.min.js:2:3003)
    at S.fn.init.each (jquery.min.js:2:1481)
    at l (bundle.js:2:9664)
    at Object.callback (bundle.js:2:11161)

The error disappeared after reverting to the previous version. From the traceback, the error should happen here:

if (weights.every(w => w === 0)) {

Did you encounter this error in every browser or was it unique to Internet Explorer 11?

njzjz commented

was it unique to Internet Explorer 11

My browser is Edge 108.0.1462.54.

njzjz commented

You can take a look at my application.
v2.0.8
image

v2.1.2
image

I catch the error and make it fallback to pure texts, but the error message can still be shown in the console.

Can confirm. This project's own example file can recreate this:
https://github.com/reymond-group/smilesDrawer/blob/master/example/index_svg.html

Changing the line:

<script src="../dist/smiles-drawer.js"></script>

To:
<script src="https://unpkg.com/smiles-drawer@2.0.3/dist/smiles-drawer.min.js"></script>

Works, while setting the version to 2.1.5 gives this error, as well as using the smiles-drawer currently in dist.