Skip to content

Parsing html template with [hidden] fails in IE9/10 #5774

Closed

Description

@wkwiatek

I just started to test app which is built on top of Angular2 in different environments and it turned out there are some issues on IE (mostly 9) and I'll try to let you know about them.

One of them is html parser. When trying to parse following lines:
<div [hidden]="!isAuthorized">

I get such error on both IE9 and IE10:
Template parse errors: Can't bind to 'hidden' since it isn't a known native property

Code above works on modern browsers like a charm.

To fix it I had to make a workaround which seem to have no problems:
<div [style.display]="isAuthorized ? 'block' : 'none'">

Activity

  1. changed the title [-]Parsing html template with [hidden] or [visible] fails in IE9/10[/-] [+]Parsing html template with [hidden] fails in IE9/10[/+] on Dec 10, 2015
  2. pkozlowski-opensource commented on Dec 10, 2015

    @pkozlowski-opensource
    Member

    @wkwiatek I presume this is because IE9 doesn't have hidden property - will try to confirm later on. If so it would need a polyffil, I'm not sure we want to work-around it in the framework (to be seen).

  3. wkwiatek commented on Dec 10, 2015

    @wkwiatek
    ContributorAuthor

    @pkozlowski-opensource Yes, there's no attribute like hidden in IE9/10 (it was introduced in IE11)

    I'm just wondering what is the preferable way of showing/hiding elements that is cross-browser compatible? I mean what's the successor of ng-show, ng-hide? If the one above is that one I would vote for it to have polyfill in angular itself.

  4. pkozlowski-opensource commented on Dec 10, 2015

    @pkozlowski-opensource
    Member

    Yes, there's no attribute like hidden in IE9/10 (it was introduced in IE11)

    @wkwiatek [hidden] means binding to a property not an attribute. So we need to check if a property exists (probably not since there is no attribute)

  5. wkwiatek commented on Dec 10, 2015

    @wkwiatek
    ContributorAuthor

    Neither property nor attribute hidden exists in IE9/10.

  6. zoechi commented on Dec 10, 2015

    @zoechi
    Contributor

    I didn't do much web development with older browsers but I haven't heard yet that attributes need to exist on an element in order to be set. Can't arbitrary custom attributes added to elements? Is it just that Angular treats the hidden attribute special or is this special with older browsers?

  7. pkozlowski-opensource commented on Dec 10, 2015

    @pkozlowski-opensource
    Member

    @zoechi once again [hidden]="exp" means binding to PROPERTY, not an attribute. And yes, a property must exist - like any other member of a class that you are trying to use.

    Of course you could do [attr.hidden]="exp" to add / remove a hidden attribute. But it won't change much if a browser is not aware of it (didn't implement any logic to show / hide stuff based on the presence of this attribute).

  8. pkozlowski-opensource commented on Dec 10, 2015

    @pkozlowski-opensource
    Member

    I'm just wondering what is the preferable way of showing/hiding elements that is cross-browser compatible?

    I would say ngIf

  9. e-oz commented on Apr 13, 2016

    @e-oz

    better alternative to slow *ngIf is combination of [attr.data-hidden] (instead of [hidden]) and rule [data-hidden="true"]{display: none !important} in global CSS.

  10. zoechi commented on Apr 13, 2016

    @zoechi
    Contributor

    I think this can be closed. The workaround @e-oz showed is the common workaround for the missing hidden support in IE9.

  11. zoechi commented on Apr 13, 2016

    @zoechi
    Contributor

    @e-oz Sorry, didn't fully formulate the sentence - updated.

  12. ocombe commented on Apr 25, 2016

    @ocombe
    Contributor

    Not really, since this is not consistent with the other browser this should be fixed: either force to use [attr.hidden] everywhere or fix it for IE9/10. I just found out that my website couldn't display in IE10 because of this.

  13. e-oz commented on Apr 25, 2016

    @e-oz

    @ocombe in IE9/10 it's better to use [attr.data-hidden], because they want to use custom attributes only with "data-" prefix.

  14. ocombe commented on Apr 25, 2016

    @ocombe
    Contributor

    They = IE ?

  15. e-oz commented on Apr 25, 2016

    @e-oz

    Yes, IE 9 and IE 10. Small group of ugly browsers.

    On Mon, 25 Apr 2016 at 18:10 Olivier Combe notifications@github.com wrote:

    They = IE ?

    —
    You are receiving this because you were mentioned.
    Reply to this email directly or view it on GitHub
    #5774 (comment)

  16. gog182 commented on May 23, 2016

    @gog182

    Would it seem normal to you that I face the same issue with IE 11 as well?

  17. zoechi commented on May 23, 2016

    @zoechi
    Contributor

    @gog182 Without a Plunker that demonstrates what you tried and allows to reproduce the issue it's hard to tell.

  18. pkozlowski-opensource commented on Jun 6, 2016

    @pkozlowski-opensource
    Member

    Going to close this one as there is no much we can do here... If a given browser doesn't support properties than it doesn't... One way to go would be to use polyffils, if possible....

  19. kuriel-dev commented on Aug 13, 2017

    @kuriel-dev

    @e-oz solution, can't handle conditional var initialization, like:

    [attr.data-hidden]="someVar"

    but works if you explicitly check var init:

    [attr.data-hidden]="someVar?true:false"

    btw, i hate you IE a lot of patches to make you run....

  20. ocombe commented on Aug 14, 2017

    @ocombe
    Contributor

    @ikuriel even simpler: [attr.data-hidden]="!!someVar"

  21. kuriel-dev commented on Aug 15, 2017

    @kuriel-dev

    yes, simpler tnx.

  22. kayode-anthony commented on Oct 25, 2017

    @kayode-anthony

    If you are using bootstrap you can also use bootstrap's hidden. Similar to the CSS solution but you don't have to add anything to the global CSS file.

  23. angular-automatic-lock-bot commented on Sep 12, 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.

  24. locked and limited conversation to collaborators on Sep 12, 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

    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