Skip to content

Boolean attributes stopped working #4150

Closed

Description

@rkj

Until recently code like this:

<div [attr.foo]="null></div>

would not set foo on the div at all, at this is very useful for interacting with html boolean attributes. In current version it produces:

<div [attr.foo]="null" foo="null"></div>

Activity

  1. pkozlowski-opensource commented on Sep 13, 2015

    @pkozlowski-opensource
    Member

    Yeh, can reproduce it with alpha.37.

  2. pkozlowski-opensource commented on Sep 13, 2015

    @pkozlowski-opensource
    Member

    OK, so this is a regression introduced in 6c3c606. We are definitively missing a test for this case, PR is on the way.

  3. typotter commented on Oct 7, 2015

    @typotter

    This bug appears to be happening again, at least in angular-dart.

  4. zoechi commented on Dec 9, 2015

    @zoechi
    Contributor

    Same here in Dart as well

    <div [attr.hidden]="false">

    results in

    <div hidden="false">
  5. zoechi commented on Dec 9, 2015

    @zoechi
    Contributor
    <div [attr.hidden]="null">

    works though, but I don't think this is satisfying.

  6. 0x-r4bbit commented on Dec 9, 2015

    @0x-r4bbit
    Contributor

    AFAIK this is the intended behaviour

  7. zoechi commented on Dec 9, 2015

    @zoechi
    Contributor

    @PascalPrecht thanks for confirming. After I found out that it works with null it got that suspicion, but I don't find this pretty.
    In Polymer when the property of type boolean is bound to an attribute, it treats it as boolean attribute. I find this a better approach.
    If I want the binding result in <div hidden="true"> I can use a string property with value "true" or "false".

  8. vicb commented on Dec 9, 2015

    @vicb
    Contributor

    Could any one create an issue for true/false to be supported ? thanks

  9. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions