@hotwired/turbo 7.1.0-rc.2 → 7.1.0-rc.3

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Turbo 7.1.0-rc.1
2
+ Turbo 7.1.0-rc.3
3
3
  Copyright © 2021 Basecamp, LLC
4
4
  */
5
5
  (function () {
@@ -404,13 +404,10 @@ class FetchRequest {
404
404
  this.delegate = delegate;
405
405
  this.method = method;
406
406
  this.headers = this.defaultHeaders;
407
- if (this.isIdempotent) {
408
- this.url = mergeFormDataEntries(location, [...body.entries()]);
409
- }
410
- else {
411
- this.body = body;
412
- this.url = location;
413
- }
407
+ this.body = body;
408
+ this.url = this.isIdempotent ?
409
+ mergeFormDataEntries(new URL(location.href), this.entries) :
410
+ location;
414
411
  this.target = target;
415
412
  }
416
413
  get location() {
@@ -466,7 +463,7 @@ class FetchRequest {
466
463
  credentials: "same-origin",
467
464
  headers: this.headers,
468
465
  redirect: "follow",
469
- body: this.body,
466
+ body: this.isIdempotent ? null : this.body,
470
467
  signal: this.abortSignal,
471
468
  referrer: (_a = this.delegate.referrer) === null || _a === void 0 ? void 0 : _a.href
472
469
  };
@@ -488,7 +485,7 @@ class FetchRequest {
488
485
  cancelable: true,
489
486
  detail: {
490
487
  fetchOptions,
491
- url: this.url.href,
488
+ url: this.url,
492
489
  resume: this.resolveRequestPromise
493
490
  },
494
491
  target: this.target
@@ -498,18 +495,13 @@ class FetchRequest {
498
495
  }
499
496
  }
500
497
  function mergeFormDataEntries(url, entries) {
501
- const currentSearchParams = new URLSearchParams(url.search);
498
+ const searchParams = new URLSearchParams;
502
499
  for (const [name, value] of entries) {
503
500
  if (value instanceof File)
504
501
  continue;
505
- if (currentSearchParams.has(name)) {
506
- currentSearchParams.delete(name);
507
- url.searchParams.set(name, value);
508
- }
509
- else {
510
- url.searchParams.append(name, value);
511
- }
502
+ searchParams.append(name, value);
512
503
  }
504
+ url.search = searchParams.toString();
513
505
  return url;
514
506
  }
515
507
 
@@ -792,7 +784,7 @@ class FormInterceptor {
792
784
  constructor(delegate, element) {
793
785
  this.submitBubbled = ((event) => {
794
786
  const form = event.target;
795
- if (form instanceof HTMLFormElement && form.closest("turbo-frame, html") == this.element) {
787
+ if (!event.defaultPrevented && form instanceof HTMLFormElement && form.closest("turbo-frame, html") == this.element) {
796
788
  const submitter = event.submitter || undefined;
797
789
  const method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formmethod")) || form.method;
798
790
  if (method != "dialog" && this.delegate.shouldInterceptFormSubmission(form, submitter)) {
@@ -1715,10 +1707,10 @@ class BrowserAdapter {
1715
1707
  this.navigator.startVisit(location, uuid(), options);
1716
1708
  }
1717
1709
  visitStarted(visit) {
1710
+ visit.loadCachedSnapshot();
1718
1711
  visit.issueRequest();
1719
1712
  visit.changeHistory();
1720
1713
  visit.goToSamePageAnchor();
1721
- visit.loadCachedSnapshot();
1722
1714
  }
1723
1715
  visitRequestStarted(visit) {
1724
1716
  this.progressBar.setValue(0);
@@ -2902,7 +2894,7 @@ class FrameController {
2902
2894
  this.currentURL = this.sourceURL;
2903
2895
  if (this.sourceURL) {
2904
2896
  try {
2905
- this.element.loaded = this.visit(this.sourceURL);
2897
+ this.element.loaded = this.visit(expandURL(this.sourceURL));
2906
2898
  this.appearanceObserver.stop();
2907
2899
  await this.element.loaded;
2908
2900
  this.hasBeenLoaded = true;
@@ -3018,7 +3010,7 @@ class FrameController {
3018
3010
  }
3019
3011
  async visit(url) {
3020
3012
  var _a;
3021
- const request = new FetchRequest(this, FetchMethod.get, expandURL(url), new URLSearchParams, this.element);
3013
+ const request = new FetchRequest(this, FetchMethod.get, url, url.searchParams, this.element);
3022
3014
  (_a = this.currentFetchRequest) === null || _a === void 0 ? void 0 : _a.cancel();
3023
3015
  this.currentFetchRequest = request;
3024
3016
  return new Promise(resolve => {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Turbo 7.1.0-rc.1
2
+ Turbo 7.1.0-rc.3
3
3
  Copyright © 2021 Basecamp, LLC
4
4
  */
5
5
  (function (global, factory) {
@@ -410,13 +410,10 @@ Copyright © 2021 Basecamp, LLC
410
410
  this.delegate = delegate;
411
411
  this.method = method;
412
412
  this.headers = this.defaultHeaders;
413
- if (this.isIdempotent) {
414
- this.url = mergeFormDataEntries(location, [...body.entries()]);
415
- }
416
- else {
417
- this.body = body;
418
- this.url = location;
419
- }
413
+ this.body = body;
414
+ this.url = this.isIdempotent ?
415
+ mergeFormDataEntries(new URL(location.href), this.entries) :
416
+ location;
420
417
  this.target = target;
421
418
  }
422
419
  get location() {
@@ -472,7 +469,7 @@ Copyright © 2021 Basecamp, LLC
472
469
  credentials: "same-origin",
473
470
  headers: this.headers,
474
471
  redirect: "follow",
475
- body: this.body,
472
+ body: this.isIdempotent ? null : this.body,
476
473
  signal: this.abortSignal,
477
474
  referrer: (_a = this.delegate.referrer) === null || _a === void 0 ? void 0 : _a.href
478
475
  };
@@ -494,7 +491,7 @@ Copyright © 2021 Basecamp, LLC
494
491
  cancelable: true,
495
492
  detail: {
496
493
  fetchOptions,
497
- url: this.url.href,
494
+ url: this.url,
498
495
  resume: this.resolveRequestPromise
499
496
  },
500
497
  target: this.target
@@ -504,18 +501,13 @@ Copyright © 2021 Basecamp, LLC
504
501
  }
505
502
  }
506
503
  function mergeFormDataEntries(url, entries) {
507
- const currentSearchParams = new URLSearchParams(url.search);
504
+ const searchParams = new URLSearchParams;
508
505
  for (const [name, value] of entries) {
509
506
  if (value instanceof File)
510
507
  continue;
511
- if (currentSearchParams.has(name)) {
512
- currentSearchParams.delete(name);
513
- url.searchParams.set(name, value);
514
- }
515
- else {
516
- url.searchParams.append(name, value);
517
- }
508
+ searchParams.append(name, value);
518
509
  }
510
+ url.search = searchParams.toString();
519
511
  return url;
520
512
  }
521
513
 
@@ -798,7 +790,7 @@ Copyright © 2021 Basecamp, LLC
798
790
  constructor(delegate, element) {
799
791
  this.submitBubbled = ((event) => {
800
792
  const form = event.target;
801
- if (form instanceof HTMLFormElement && form.closest("turbo-frame, html") == this.element) {
793
+ if (!event.defaultPrevented && form instanceof HTMLFormElement && form.closest("turbo-frame, html") == this.element) {
802
794
  const submitter = event.submitter || undefined;
803
795
  const method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formmethod")) || form.method;
804
796
  if (method != "dialog" && this.delegate.shouldInterceptFormSubmission(form, submitter)) {
@@ -1721,10 +1713,10 @@ Copyright © 2021 Basecamp, LLC
1721
1713
  this.navigator.startVisit(location, uuid(), options);
1722
1714
  }
1723
1715
  visitStarted(visit) {
1716
+ visit.loadCachedSnapshot();
1724
1717
  visit.issueRequest();
1725
1718
  visit.changeHistory();
1726
1719
  visit.goToSamePageAnchor();
1727
- visit.loadCachedSnapshot();
1728
1720
  }
1729
1721
  visitRequestStarted(visit) {
1730
1722
  this.progressBar.setValue(0);
@@ -2908,7 +2900,7 @@ Copyright © 2021 Basecamp, LLC
2908
2900
  this.currentURL = this.sourceURL;
2909
2901
  if (this.sourceURL) {
2910
2902
  try {
2911
- this.element.loaded = this.visit(this.sourceURL);
2903
+ this.element.loaded = this.visit(expandURL(this.sourceURL));
2912
2904
  this.appearanceObserver.stop();
2913
2905
  await this.element.loaded;
2914
2906
  this.hasBeenLoaded = true;
@@ -3024,7 +3016,7 @@ Copyright © 2021 Basecamp, LLC
3024
3016
  }
3025
3017
  async visit(url) {
3026
3018
  var _a;
3027
- const request = new FetchRequest(this, FetchMethod.get, expandURL(url), new URLSearchParams, this.element);
3019
+ const request = new FetchRequest(this, FetchMethod.get, url, url.searchParams, this.element);
3028
3020
  (_a = this.currentFetchRequest) === null || _a === void 0 ? void 0 : _a.cancel();
3029
3021
  this.currentFetchRequest = request;
3030
3022
  return new Promise(resolve => {
@@ -8,9 +8,13 @@ export declare class FormSubmissionTests extends TurboDriveTestCase {
8
8
  "test standard form submission does not render a progress bar before expiring the delay"(): Promise<void>;
9
9
  "test standard form submission with redirect response"(): Promise<void>;
10
10
  "test standard POST form submission events"(): Promise<void>;
11
+ "test standard POST form submission merges values from both searchParams and body"(): Promise<void>;
11
12
  "test standard POST form submission toggles submitter [disabled] attribute"(): Promise<void>;
12
13
  "test standard GET form submission"(): Promise<void>;
13
14
  "test standard GET form submission events"(): Promise<void>;
15
+ "test standard GET form submission does not incorporate the current page's URLSearchParams values into the submission"(): Promise<void>;
16
+ "test standard GET form submission does not merge values into the [action] attribute"(): Promise<void>;
17
+ "test standard GET form submission omits the [action] value's URLSearchParams from the submission"(): Promise<void>;
14
18
  "test standard GET form submission toggles submitter [disabled] attribute"(): Promise<void>;
15
19
  "test standard GET form submission appending keys"(): Promise<void>;
16
20
  "test standard form submission with empty created response"(): Promise<void>;
@@ -50,6 +54,7 @@ export declare class FormSubmissionTests extends TurboDriveTestCase {
50
54
  "test frame form submission with HTTP verb other than GET or POST"(): Promise<void>;
51
55
  "test frame form submission with [data-turbo=false] on the form"(): Promise<void>;
52
56
  "test frame form submission with [data-turbo=false] on the submitter"(): Promise<void>;
57
+ "test frame form submission ignores submissions with their defaultPrevented"(): Promise<void>;
53
58
  "test form submission with [data-turbo=false] on the form"(): Promise<void>;
54
59
  "test form submission with [data-turbo=false] on the submitter"(): Promise<void>;
55
60
  "test form submission skipped within method=dialog"(): Promise<void>;
@@ -8,6 +8,7 @@ export declare class VisitTests extends TurboDriveTestCase {
8
8
  "test navigation by history is not cancelable"(): Promise<void>;
9
9
  "test turbo:before-fetch-request event.detail"(): Promise<void>;
10
10
  "test turbo:before-fetch-response open new site"(): Promise<void>;
11
+ "test cache does not override response after redirect"(): Promise<void>;
11
12
  visitLocation(location: string): Promise<void>;
12
13
  cancelNextVisit(): Promise<void>;
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwired/turbo",
3
- "version": "7.1.0-rc.2",
3
+ "version": "7.1.0-rc.3",
4
4
  "description": "The speed of a single-page web application without having to write any JavaScript",
5
5
  "module": "dist/turbo.es2017-esm.js",
6
6
  "main": "dist/turbo.es2017-umd.js",