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

Redundant statement in RoughAnnotationImpl.show() #71

Open
ryan-di opened this issue Jun 3, 2022 · 1 comment
Open

Redundant statement in RoughAnnotationImpl.show() #71

ryan-di opened this issue Jun 3, 2022 · 1 comment

Comments

@ryan-di
Copy link

ryan-di commented Jun 3, 2022

Given that the AnnotationState is

type AnnotationState = 'unattached' | 'not-showing' | 'showing';

and when we call the private attach() method, we first check if the state is 'unattached'

private attach() {
  if (this._state === 'unattached' && this._e.parentElement) {
    // ...
  }
}

I think the this.attach() statement in the 'not-showing' case is redundant.

show(): void {
  switch (this._state) {
    case 'unattached':
      // ...
    case 'showing':
      // ...
    case 'not-showing':
      this.attach();
      if (this._svg) {
        this.render(this._svg, false);
      }
      break;
  }
}

Not sure if I'm missing anything : )

@pshihn
Copy link
Collaborator

pshihn commented Jun 3, 2022

You're probably right. It's redundant but benign as well.
I'll have to think of why this was added. Wish I had commented the code :)

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

No branches or pull requests

2 participants