add - PeterNaydenov/code-assembly-line GitHub Wiki

Add properties and values to current-data items.

Fields

    { 
         do: 'add'
       , select?: items
       , data: changes 
    }

Types

  • items: string | number | Array < string | number >. Represent elements in the list. There are few predefined values: 'first','last','all'. Use number to define element from start to end or (-number) from end to start. Missing selection param is equal to: select: ['all']
  • changes: { key : value }

Example

    [
        { do: 'add', data: {'className': 'navItem'} }
      , { do: 'add', select:'first', data: {'className': 'firstItem'} }
    ]

All elements will obtain className 'navItem'. Only first record will add 'firstItem'. Because className property already has a value result will be className = 'navItem firstItem'.

Add more than one value with one 'add' process-step:

     [
        { do: 'add', data: {'className': 'navItem'} }
      , { do: 'add', select:'first', data: {'className': ['firstItem','selected']} }
      ]

The first element in data will have className = 'navItem firstItem selected'