@primate/core 0.9.17 → 0.9.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,7 +53,10 @@ export default (frontend, u) => {
53
53
  const { enctype } = target;
54
54
  const action = target.getAttribute("action") ?? location.href;
55
55
  const url = new URL(action, location.href);
56
- const data = new FormData(target);
56
+ const submitter = event.submitter;
57
+ const data = submitter === null
58
+ ? new FormData(target)
59
+ : new FormData(target, submitter);
57
60
  const form = enctype === http.MIME.MULTIPART_FORM_DATA
58
61
  ? data
59
62
  : new URLSearchParams(data);
@@ -122,7 +122,10 @@ function createForm(init) {
122
122
  const url = init.url
123
123
  ?? form_element.getAttribute("action")
124
124
  ?? globalThis.location.href;
125
- const form_data = new FormData(form_element);
125
+ const submitter = event?.submitter;
126
+ const form_data = submitter === null || submitter === undefined
127
+ ? new FormData(form_element)
128
+ : new FormData(form_element, submitter);
126
129
  setSubmitting(true);
127
130
  try {
128
131
  const response = await (is.defined(init.action)
@@ -46,23 +46,26 @@ async function goto(target, state = false, after) {
46
46
  }
47
47
  }
48
48
  async function go(href, event) {
49
- const url = new URL(href);
50
- const { hash, pathname } = url;
51
49
  const { location } = globalThis;
52
- if (url.host === location.host) {
53
- event?.preventDefault();
54
- if (location.pathname !== pathname) {
55
- await goto(url, true, () => {
56
- scroll_hash(hash);
57
- globalThis.dispatchEvent(new Event("updated"));
58
- });
59
- }
60
- if (location.hash !== hash) {
61
- const { scrollTop } = globalThis.document.scrollingElement;
62
- storage.new({ hash: location.hash, pathname: location.pathname, scrollTop, stop: true });
63
- history.pushState(null, "", `${location.pathname}${hash}`);
50
+ const url = new URL(href, location.href);
51
+ const { hash, pathname, search } = url;
52
+ if (url.origin !== location.origin) {
53
+ if (event === undefined)
54
+ location.assign(url.toString());
55
+ return;
56
+ }
57
+ event?.preventDefault();
58
+ if (location.pathname !== pathname || location.search !== search) {
59
+ await goto(url, true, () => {
64
60
  scroll_hash(hash);
65
- }
61
+ globalThis.dispatchEvent(new Event("updated"));
62
+ });
63
+ }
64
+ if (location.hash !== hash) {
65
+ const { scrollTop } = globalThis.document.scrollingElement;
66
+ storage.new({ hash: location.hash, pathname: location.pathname, scrollTop, stop: true });
67
+ history.pushState(null, "", `${location.pathname}${location.search}${hash}`);
68
+ scroll_hash(hash);
66
69
  }
67
70
  }
68
71
  const navigate = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primate/core",
3
- "version": "0.9.17",
3
+ "version": "0.9.19",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",