intercellular / cell

A self-driving web app framework
https://www.celljs.org
MIT License
1.5k stars 93 forks source link

Select multiple and attribute order #176

Open lachdoug opened 6 years ago

lachdoug commented 6 years ago

Below are two objects that define forms with select/multiple fields. myForm works: all three options render selected. myForm2 differs from myForm in that on the select field the 'multiple' attribute is defined after the '$components' attribute. In this case only the last option renders as selected.

screenshot from 2018-05-13 22-26-06

I would have thought that the attribute order should not matter. Am I misunderstanding something? I can't find anything in the docs that suggests that $components must be defined after other attributes.

myForm = {
  $cell: true,
  $type: "form",
  $components: [
    {
      $type: "select",
      name: "select[]",
      multiple: true,
      $components: [
        {
          $type: "option",
          $text: "First option",
          selected: true
        },
        {
          $type: "option",
          $text: "Second option",
          selected: true
        },
        {
          $type: "option",
          $text: "Third option",
          selected: true
        },
      ]
    }
  ]
};
myForm2 = {
  $cell: true,
  $type: "form",
  $components: [
    {
      $type: "select",
      name: "select[]",
      $components: [
        {
          $type: "option",
          $text: "First option",
          selected: true
        },
        {
          $type: "option",
          $text: "Second option",
          selected: true
        },
        {
          $type: "option",
          $text: "Third option",
          selected: true
        },
      ],
      multiple: true
    }
  ]
};