MCPcopy
hub / github.com/docsifyjs/docsify / onchange

Method onchange

src/core/router/history/html5.js:23–38  ·  view source on GitHub ↗
(cb = noop)

Source from the content-addressed store, hash-verified

21 }
22
23 onchange(cb = noop) {
24 on('click', e => {
25 const el = e.target.tagName === 'A' ? e.target : e.target.parentNode;
26
27 if (el && el.tagName === 'A' && !isExternal(el.href)) {
28 e.preventDefault();
29 const url = el.href;
30 window.history.pushState({ key: url }, '', url);
31 cb({ event: e, source: 'navigate' });
32 }
33 });
34
35 on('popstate', e => {
36 cb({ event: e, source: 'history' });
37 });
38 }
39
40 /**
41 * Parse the url

Callers

nothing calls this directly

Calls 2

onFunction · 0.90
isExternalFunction · 0.90

Tested by

no test coverage detected