Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass default value weights = null to SvgDrawer.draw() #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

panda-byte
Copy link

Resolves #171. Although the weights parameter was added to SvgDrawer.draw() in f3693b3, the method call in Drawer.draw() wasn't updated correspondingly. Drawer.draw() could be amended to also take a weights argument, which it would pass to SvgDrawer.draw(), but this might break existing code even more and would require an update of the documentation of the README.

Example to reproduce:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="dist/smiles-drawer.js"></script>
</head>
<body>
<canvas id="canvas" style="width: 200px; height: 200px; background-color: lightgrey"></canvas>

<script>
    SmilesDrawer.parse(
        "CCCNC",
        tree => {
            (new SmilesDrawer.Drawer()).draw(tree, 'canvas');
        },
        alert
    );
</script>
</body>
</html>

Before the proposed change, this gives an error (TypeError: this.svgWrapper is null). With the proposed change, the error is resolved and the structure is displayed correctly.

…r.draw()`

Resolves reymond-group#171. Although the `weights` parameter was added to
`SvgDrawer.draw()` in f3693b3, the method call in `Drawer.draw()` wasn't
updated correspondingly. `Drawer.draw()` could be amended to also take a
`weights` argument, which it would pass to `SvgDrawer.draw()`, but this might
break existing code even more and would require an update of the
documentation of the README.
@netlify
Copy link

netlify bot commented Jun 15, 2023

Deploy Preview for smilesdrawer-doc canceled.

Name Link
🔨 Latest commit 2c5d7ab
🔍 Latest deploy log https://app.netlify.com/sites/smilesdrawer-doc/deploys/648b7fc33f4a60000840defc

@njzjz
Copy link

njzjz commented Oct 25, 2023

It should also fix #161

Copy link

@CrazydduGi CrazydduGi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
I have a same problem but it solves that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible Error in constructors
4 participants