slim-select icon indicating copy to clipboard operation
slim-select copied to clipboard

Parse data attributes from HTML options

Open DDeBruler opened this issue 2 years ago • 0 comments

As described in current documentation, "Slim select will take on attributes of the original as best as possible" and that holds up for classes, styles, etc. But even in the live docs page, the "data attributes" option doesn't actually take on the data attributes of the original as

<select id="optionsSingle">
  <option data-placeholder="true"></option>
  <option value="value1" data-info="Here is info">Data Attributes</option>
  <option value="value2" disabled="disabled">Disabled Option</option>
  <option value="value3" class="green">Class Green</option>
  <option value="value3" style="color: purple;">Inline Style</option>
</select>

results in a list with

<div class="ss-list" role="listbox">
  <div class="ss-option ss-hide"></div>
  <div class="ss-option" role="option" data-id="96806269">Data Attributes</div>
  <div class="ss-option ss-disabled" role="option" data-id="94115850">Disabled Option</div>
  <div class="ss-option green" role="option" data-id="49570720">Class Green</div>
  <div class="ss-option" role="option" style="color: purple;" data-id="78783995">Inline Style</div>
</div>

This change takes the working parsing logic from Select that runs when adding options dynamically and includes is in the Slim method that initially adds options from the option tag.

DDeBruler avatar Jul 14 '22 20:07 DDeBruler