Skip to content

Error in documentation #1328

@evalcurious

Description

@evalcurious

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions