reymond-group / smilesDrawer

A small, highly performant JavaScript component for parsing and drawing SMILES strings. Released under the MIT license.
https://smilesdrawer.rocks
MIT License
437 stars 70 forks source link

TypeError: weights.every is not a function #161

Open njzjz opened 1 year ago

njzjz commented 1 year ago

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:

https://github.com/reymond-group/smilesDrawer/blob/667680960074365ae2b93f09a468c75a7872d4c4/src/SvgDrawer.js#L410

daenuprobst commented 1 year ago

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

njzjz commented 1 year ago

was it unique to Internet Explorer 11

My browser is Edge 108.0.1462.54.

njzjz commented 1 year ago

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.

dwrolvink commented 1 year ago

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: https://github.com/reymond-group/smilesDrawer/blob/67bd1065fef1d7fb6246db7d6ded758c6f43a91a/example/index_svg.html#L11

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.