Conditional `if` does not work as expected with select tag and dynamic options #2229

Closed
Infeligo opened this Issue Jan 20, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@Infeligo

Help us to manage our issues by answering the following:

  1. Describe your issue:

I wanted to used if attribute on select tag with dynamic options like this:

  <select if={ showSelect }>
    <option each={ list } value={ value }>{ text }</option>
  </select>

However, when if expression value toggles, unexpected artifacts in form of empty selects are left in the DOM.

  1. Can you reproduce the issue?

http://plnkr.co/edit/yPRenJjTIthlG3CPEoPz?p=preview
(click "Toggle" button multiple times to reproduce this issue)

  1. On which browser/OS does the issue appear?

Chrome 55 and Firefox 49 on Windows 8.1

  1. Which version of Riot does it affect?

At least Riot 3.0.7

  1. How would you tag this issue?
  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@rbatistajs

This comment has been minimized.

Show comment
Hide comment
@rbatistajs

rbatistajs Jan 20, 2017

I made a test by removing the "else" from that line
https://github.com/riot/riot/blob/master/lib/browser/tag/if.js#L37

Getting +/- like this

if (this.current._tag)
    this.current._tag.unmount()

if (this.current.parentNode)
    this.current.parentNode.removeChild(this.current)

I did the test and it worked, just don't know if it's the correct solution.

(Sorry for my bad english)

I made a test by removing the "else" from that line
https://github.com/riot/riot/blob/master/lib/browser/tag/if.js#L37

Getting +/- like this

if (this.current._tag)
    this.current._tag.unmount()

if (this.current.parentNode)
    this.current.parentNode.removeChild(this.current)

I did the test and it worked, just don't know if it's the correct solution.

(Sorry for my bad english)

@GianlucaGuarini

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini

GianlucaGuarini Jan 21, 2017

Member

thank you @rbatistajs I will work on a patch soon

Member

GianlucaGuarini commented Jan 21, 2017

thank you @rbatistajs I will work on a patch soon

GianlucaGuarini added a commit that referenced this issue Jan 28, 2017

GianlucaGuarini added a commit that referenced this issue Jan 28, 2017

Merge branch 'bug/2229' into dev
* bug/2229:
  closes #2229
  added: test for #2229

@fabien fabien referenced this issue Feb 5, 2017

Closed

Uncaught TypeError in global mixin init #2248

1 of 7 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment