question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional `repeat` directive not removed from DOM

See original GitHub issue

Description

When using a repeat directive that is based on a condition, and if that condition changes such that the repeat directive will not be rendered anymore, the elements previously generated by repeat are not removed from the DOM.

Steps to Reproduce

Put a repeat directive behind a condition.

Live Reproduction Link

https://stackblitz.com/edit/u25pbw-jjbfqw (open console)

Expected Results

Repeat DOM disappears when condition changes to false.

Actual Results

Repeat DOM does not disappear.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
simonfuhrmanncommented, Sep 12, 2019

Interestingly with nothing the repeat elements disappear, but they don’t reappear.

While moving the condition to the list, not the repeat itself, is a neat work-around for this toy example, in reality things are more complicated if the condition is further up the DOM hierarchy. The fact that “this is somewhat expected [because] they generally don’t work well when used conditionally” is not something that is obvious to users of the library, and clearly not intended behavior. That’s why I think this should be considered a bug.

0reactions
justinfagnanicommented, Apr 18, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional `repeat` directive not removed from DOM · Issue #1007 ...
Description When using a repeat directive that is based on a condition, and if that condition changes such that the repeat directive will...
Read more >
Built-in directives - Lit.dev
If no keyFn is provided, repeat will perform similar to a simple map of items to values, and DOM will be reused against...
Read more >
angular - Apply a directive conditionally - Stack Overflow
Currently, there is NO way to conditionally apply a directive to a ... The components which you have created can be added or...
Read more >
Using Directives - FAST design system
The when directive enables you to conditionally render blocks of HTML. ... Whether or not a repeat directive re-uses item views can be...
Read more >
Built-in directives - Angular
Add or remove an element by applying an NgIf directive to a host element. When NgIf is false , Angular removes an element...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found