aurelia / templating-binding

An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.
MIT License
32 stars 26 forks source link

Support for ES6 Sets #34

Closed chandmk closed 8 years ago

chandmk commented 9 years ago

Binding repeat.for over a set does nothing


export class Test{
  constructor(){
    this.list = new Set(["foo", "bar", "foo"]);
  }
}
<template>
  <section>
    <ul>
      <li repeat.for="l of list">${l}</li>
    </ul>
</section>
</template>

Following works fine

this.list = Array.from(new Set(["foo", "bar", "foo"]))
EisenbergEffect commented 9 years ago

@jdanyow @martingust How hard would it be to add this do you think?

martingust commented 9 years ago

@jdanyow @EisenbergEffect We will need to patch a Set observer and update the repeater to handle Set object, I think the current for syntax should be good already . A lot of work we could grab from the Map implementation or maybe even refactor some stuff to handle both Map and Set objects. It would be nice to have this in place for beta. Maybe we could split up some work, what you guys think?

jdanyow commented 9 years ago

:+1: looks like a lot of the work you've done for Map can be used for Set. Do you guys think it's worth making the repeat pluggable so users can add implementations for other collection implementations or is it better to handle the core ES6 cases as we have been and use converters for other cases?

EisenbergEffect commented 9 years ago

@jdanyow If you don't think that would be too hard, I think that's a great idea.

martingust commented 9 years ago

@jdanyow @EisenbergEffect That would be pretty cool. Another idea since its all just an array in the end, maybe we could handle everything, Map, Set etc, only in bindingand always provide the repeater with arrays no matter of underlying type. haven't really thought it through or tested anything but it would remove a lot of duplicate logic in the repeater.