next/prev commands

Refactored next/prev commands. @lydell would you like to review before merging?
Then perhaps we should match `role` just like `rel`? To me it feels like pattern matching should only be used on text and attributes that has text as its value (as opposed to keywords), like `data-tooltip` and `aria-label`.