Skip to content

dom-if template got rendered once even if the condition is false #1663

Closed
@namiwang

Description

Say I got something like this:

<dom-module id="what-ever">
  <template is="dom-if" if="{{foo.bar}}">
    <div>{{someComputedProperty(foo)}}</div>
  </template>
  <template is="dom-if" if="{{foo.baz}}">
    <div>{{someOtherComputedProperty(foo)}}</div>
  </template>
</dom-module>
Polymer
  someComputedProperty: () ->
    # computed some value rely on foo.bar being true
    return 'foo.bar is: ' + foo.bar
  someOtherComputedProperty: () ->
    # computed some value rely on foo.baz being true
    return 'foo.baz is: ' + foo.baz

When foo is changing from

{ bar: true, baz: false }

to

{ bar: false, baz: true }

The first template still got rendered, and that may cause some issue, since the method someComputedProperty always assumes foo.bar being true.

Additionally it's seems like wasting of performance, since it's rendering a template which should not be.

So I'm wondering is this a bug and what can I do for now.

Thx.

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