Skip to content
Discussion options

You must be logged in to vote

Hi, use preinitialize() — that's the hook for exactly this case:

class PortHandle extends mvc.View<undefined, SVGElement> {
    preinitialize() {
        this.tagName = 'circle';
        this.svgElement = true;
    }

    // the rest as regular class members
}

Same applies to any property read while the element is being created: className, attributes, style, id, events, and svgElement (without the latter your circle ends up in the XHTML namespace instead of SVG, and this.vel is never set up). Everything read later (children, DETACHABLE, UPDATE_PRIORITY, your own state and methods) is fine as a normal class field.

mvc.View inherits Backbone's constructor contract, and preinitialize was add…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vaclavHala
Comment options

Answer selected by vaclavHala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants