UNPKG

pagestate

Version:

Using the CSS target: pseudo selector it is possible to apply style variations based upon the fragment identifier of the URI of a HTML document.

1 lines 554 B
!function(e,t,a){"use strict";function r(){return i=!0,""===t.hash?!1:void 0}function n(e){if(!e.defaultPrevented){for(var r=e.target;"A"!==r.tagName&&r.parentNode;)r=r.parentNode;if("A"===r.tagName&&"#state-"===t.hash.substr(0,7)){var n=r.href.indexOf("#");if(-1!==n){var s=t.href,h=s.indexOf("#"),f=s.substr(0,-1!==h?h:void 0);r.href.substr(0,n)===f&&(e.preventDefault(),r.hash?t.replace(r.hash):i?a.go(-1):(t.replace("#"),a.replaceState({},"",f)))}}}}e.addEventListener("hashchange",r),e.addEventListener("click",n);var i=!1}(window,location,history);