Skip to content

Mutating element attributes leaves behind empty ones #1722

Description

I have links that I'm writing out where if they're disabled I'm leaving the href as undefined:

    render: function() {
        var href = this.props.disabled ? undefined : this.props.url;
        return <a href={href}>{this.props.title}</a>;
    }

When this first renders (disabled) the HTML DOM I get looks like this:

<a>Foo</a>

When the state changes and it's re-rendered enabled it looks like this:

<a href="#/hello">Foo</a>

All good so far, however if it then disables again, the href attribute is left in with no value:

<a href >Foo</a>

This means it still gets the styles for being a link and will receive focus.

For me it should be consistent for both disabled states.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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