<!--
Extends core-selector to support reprojected content.

This lets you include a content element within the selector and select the
distributed nodes rather than the content element itself.

@element basic-selector
-->

<link rel="import" href="../core-selector/core-selector.html">
<link rel="import" href="../basic-element/basic-element.html">

<polymer-element name="basic-selector" extends="core-selector">
<script>
Polymer( Platform.mixin( BasicWebComponents, {

  // Override the basic items property so we can handle (re)distributed content.
  // TODO: Handle selectors, etc., like base class' items can.
  get items() {
    return this.flattenChildren;
  },

  // Override the base implementation of selectedIndex to return -1 if nothing
  // is selected, which seems more helpful.
  // TODO: Handle valueattr: selected can indicate a value, not the index.
  get selectedIndex() {
    var index = this.selected;
    return index || -1;
  }
  
}));
</script>
</polymer-element>

<!--
Extends core-selector to support reprojected content.

This lets you include a content element within the selector and select the
distributed nodes rather than the content element itself.

By default, this component also ignores any template elements in the content,
making it easy to use templates to expand out a list of choices.

@element basic-selector
-->

<link rel="import" href="../core-selector/core-selector.html">
<link rel="import" href="../basic-element/basic-element.html">

<polymer-element name="basic-selector" extends="core-selector">
<script>
Polymer( Platform.mixin( BasicWebComponents, {

  excludedLocalNames: "template",

  // Override the basic items property so we can handle (re)distributed content.
  // TODO: Handle selectors, etc., like base class' items can.
  get items() {
    var flattened = this.flattenChildren;
    var filtered = Array.prototype.filter.call( flattened, this.itemFilter );
    return filtered;
  },

  // Override the base implementation of selectedIndex to return -1 if nothing
  // is selected, which seems more helpful.
  // TODO: Handle valueattr: selected can indicate a value, not the index.
  get selectedIndex() {
    var index = this.selected;
    return index || -1;
  }
  
}));
</script>
</polymer-element>

Exclude <template> elements from user selections.
Exclude <template> elements from user selections.
