MCPcopy Index your code
hub / github.com/devote/HTML5-History-API / onHashChange

Function onHashChange

history.js:882–910  ·  view source on GitHub ↗

* Event handler function changes the hash in the address bar * * @param {Event} event * @return void

(event)

Source from the content-addressed store, hash-verified

880 * @return void
881 */
882 function onHashChange(event) {
883 // https://github.com/devote/HTML5-History-API/issues/46
884 var fireNow = lastURL;
885 // new value to lastURL
886 lastURL = windowLocation.href;
887 // if not empty fireNow, otherwise skipped the current handler event
888 if (fireNow) {
889 // if checkUrlForPopState equal current url, this means that the event was raised popstate browser
890 if (checkUrlForPopState !== windowLocation.href) {
891 // otherwise,
892 // the browser does not support popstate event or just does not run the event by changing the hash.
893 firePopState();
894 }
895 // current event object
896 event = event || global.event;
897
898 var oldURLObject = parseURL(fireNow, true);
899 var newURLObject = parseURL();
900 // HTML4 browser not support properties oldURL/newURL
901 if (!event.oldURL) {
902 event.oldURL = oldURLObject._href;
903 event.newURL = newURLObject._href;
904 }
905 if (oldURLObject._hash !== newURLObject._hash) {
906 // if current hash not equal previous hash
907 dispatchEvent(event);
908 }
909 }
910 }
911
912 /**
913 * The event handler is fully loaded document

Callers

nothing calls this directly

Calls 3

firePopStateFunction · 0.70
parseURLFunction · 0.70
dispatchEventFunction · 0.70

Tested by

no test coverage detected