voldsoftware/menuitems-jplib — pull request #2 by mykmelez (2012-09-11 23:41:39+00:00)
Title: fix issues preventing menuitem from appearing in menu

I ran into three issues while trying to use this module to create a menuitem:

1. The code tests `options.menuid.length` to determine if `options.menuid` is an array, as opposed to a string; but strings have `length` too. This change uses `Array.isArray()` instead.
2. When `options.menuid` is a string, `parent` isn't defined before it is used. This change defines it.
3. When `options.insertbefore` is a string, `insertBefore()` treats it as an element rather than the ID of an element. But the example in the docs suggest it should be treated as an ID. This change treats it as an ID and uses `Element.querySelector()` to retrieve the descendant with that ID.