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

Error in documentation #1328

Open
evalcurious opened this issue Oct 20, 2024 · 1 comment
Open

Error in documentation #1328

evalcurious opened this issue Oct 20, 2024 · 1 comment

Comments

@evalcurious
Copy link

Hello,

I found a couple errors in the documentation for Extending, specifically in the "Subclassing" section.

The first codeblock (reproduced below) has two errors:

  • a colon that should be an equals sign in the third line
  • a close parenthesis in the 11th line that should be in the final line instead

Reproduced codeblock:

SVG.Rounded = class extends SVG.Rect{
  // Create method to proportionally scale the rounded corners
  size: function(width, height) {
    return this.attr({
      width:  width
    , height: height
    , rx:     height / 5
    , ry:     height / 5
    })
  }
})

// Add a method to create a rounded rect
SVG.extend(SVG.Container,  {
  // Create a rounded element
  rounded: function(width, height) {
    return this.put(new SVG.Rounded).size(width, height)
  }
}

And the edited code block with corrections:

SVG.Rounded = class extends SVG.Rect{
  // Create method to proportionally scale the rounded corners
  size = function(width, height) {
    return this.attr({
      width:  width
    , height: height
    , rx:     height / 5
    , ry:     height / 5
    })
  }
}

// Add a method to create a rounded rect
SVG.extend(SVG.Container,  {
  // Create a rounded element
  rounded: function(width, height) {
    return this.put(new SVG.Rounded).size(width, height)
  }
})

The example code stumped me when it didn't work the first time I tried it, so I thought I'd flag the errors. Hope others find it helpful!

@Fuzzyma
Copy link
Member

Fuzzyma commented Oct 20, 2024

Thanks for reporting!
The first error you found should actually read size(width, height) {...} instead.

Can you open a pr to fix this? :)

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

3 participants
@Fuzzyma @evalcurious and others