john32b/djFlixel

Empty-label check does not work as expected ?

T1mL3arn opened this issue · 2 comments

Looks like empty-label check does not work as expected.

// for some reason it is empty string
var label = '';

menu.createMenuPag('foo')
  .add('
-| hello | link | hello_link
-| ${label} | link | empty_link
  ');
Uncaught exception - Wrong MenuItemType at "link" Typo?

// Get : Label, ItemType, ItemID - which are required for all ItemTypes -
label = F.shift();
if (label == null) throw 'MenuItem Must have a Label';
try{
type = EnumTools.createByName(MItemType, F.shift());
} catch (_) throw 'Wrong MenuItemType at "$label" Typo?';

Though it caught the problem with empty label, it was not clear at first what is the reason.

good catch,
oh yeah, now that I am looking at the code, it completely ignores the empty | | fields, as if they don't exist, I don't remember why I did that 🤔. Perhaps to quickly remove the first and last | ?

I'll look into this

That should do the trick. I don't think I broke anything