add assertion to catch failed attribute creation

This problem was surfaced by issue #268. We weren't doing a proper check for failed attribute creation in the attr method. This still fails and segaults, but the reason is now obvious.
HTML document throws better errors when there is no root node

HTML documents have lax parsing and can be created even without a root node. This results in errors when the document defers methods to the root node. This patch catches that circumstance and throws more descriptive errors to let you know what went wrong.
Merge pull request #266 from polotek/handle-empty-doc

HTML document throws better errors when there is no root node
Merge pull request #269 from polotek/attr-segfault-gh268

add assertion to catch failed attribute creation
Merge branch 'master' into better-text-node-support
add methods for inserting text siblings to Element class

The addPrevText and addNextText methods enable the ability to insert text
siblings before or after a given element.