What about checking the parent <menu> element if it has a type="context" attribute instead of indexOf('menu')?