If any switches are async, the subsequent code will execute before
the switches are finished. This commit moves all that code to a new
function, and debounces the calls to onSwitch() so it only executes
once, after all the switches finish.
Fizes #72.
Clone attribute nodes before setting on `oldEl` to prevent the following error:
```
DOMException: Failed to execute 'setNamedItem' on 'NamedNodeMap': The node provided is an attribute node that is already an attribute of another Element; attribute nodes must be explicitly cloned.
```
Fixes#7
This checks for redirects by looking for the following, in sequence:
- XMLHttpRequest.responseURL
- the X-PJAX-URL header (like jquery-pjax)
- the X-XHR-Redirected-To header (like Turbolinks)
Events triggered on top level elements (such as window or document)
lead to a HierarchyRequestError due to a fix in IE browsers
where dispatchEvent does not fire if an element is not in the DOM.
The current test is simply to check for the existence of parentNode
However, this means top level elements get added to itself, causing
the error.
The proposed fix simply tests for top level elements in the test.
also added test for uniqueid. only test that two calls to uniqueid return unique enties. had to modify the output slightly and added a counter to the system otherwise two back to back calls would return the same value.