ad-si / shaven

DOM building utility & Template engine based on JsonML + syntax sugar

Home Page:https://shaven.ad-si.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined should be valid value for first element of sub-arrays

adius opened this issue · comments

I assume this is for things like

['div#pagination', [
  renderPrev(),
  renderNext()
]]

Where renderPrev() might return undefined if there is no Prev button to display. I.e., the user is already on page 1.

What other circumstance would undefined be OK?

I was just about to implement this, but realized this is maybe not a good idea
as it's not clear if it's really supposed to be a sub-array.

E.g. Was this

['article',
  [
    undefined,
    ['p'],
    ['p']
  ]
]

supposed to mean

['article',
  [
    ['p'],
    ['p'],
    ['p']
  ]
]

or

['article',
  ['section',
    ['p'],
    ['p']
  ]
]

I'd rather think option 2. So the undefined should be an error.
If one wants to make sure that the array contains no undefined,
it can simply be prevented with array.filter(element => Boolean(element))