@hotwired/turbo 7.1.0-rc.3 → 7.1.0

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.3
2
+ Turbo 7.1.0
3
3
  Copyright © 2021 Basecamp, LLC
4
4
  */
5
5
  (function () {
@@ -405,9 +405,7 @@ class FetchRequest {
405
405
  this.method = method;
406
406
  this.headers = this.defaultHeaders;
407
407
  this.body = body;
408
- this.url = this.isIdempotent ?
409
- mergeFormDataEntries(new URL(location.href), this.entries) :
410
- location;
408
+ this.url = location;
411
409
  this.target = target;
412
410
  }
413
411
  get location() {
@@ -494,16 +492,6 @@ class FetchRequest {
494
492
  await requestInterception;
495
493
  }
496
494
  }
497
- function mergeFormDataEntries(url, entries) {
498
- const searchParams = new URLSearchParams;
499
- for (const [name, value] of entries) {
500
- if (value instanceof File)
501
- continue;
502
- searchParams.append(name, value);
503
- }
504
- url.search = searchParams.toString();
505
- return url;
506
- }
507
495
 
508
496
  class AppearanceObserver {
509
497
  constructor(delegate, element) {
@@ -597,6 +585,10 @@ class FormSubmission {
597
585
  this.formElement = formElement;
598
586
  this.submitter = submitter;
599
587
  this.formData = buildFormData(formElement, submitter);
588
+ this.location = expandURL(this.action);
589
+ if (this.method == FetchMethod.get) {
590
+ mergeFormDataEntries(this.location, [...this.body.entries()]);
591
+ }
600
592
  this.fetchRequest = new FetchRequest(this, this.method, this.location, this.body, this.formElement);
601
593
  this.mustRedirect = mustRedirect;
602
594
  }
@@ -613,9 +605,6 @@ class FormSubmission {
613
605
  const formElementAction = typeof this.formElement.action === 'string' ? this.formElement.action : null;
614
606
  return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formaction")) || this.formElement.getAttribute("action") || formElementAction || "";
615
607
  }
616
- get location() {
617
- return expandURL(this.action);
618
- }
619
608
  get body() {
620
609
  if (this.enctype == FormEnctype.urlEncoded || this.method == FetchMethod.get) {
621
610
  return new URLSearchParams(this.stringFormData);
@@ -741,6 +730,16 @@ function getMetaContent(name) {
741
730
  function responseSucceededWithoutRedirect(response) {
742
731
  return response.statusCode == 200 && !response.redirected;
743
732
  }
733
+ function mergeFormDataEntries(url, entries) {
734
+ const searchParams = new URLSearchParams;
735
+ for (const [name, value] of entries) {
736
+ if (value instanceof File)
737
+ continue;
738
+ searchParams.append(name, value);
739
+ }
740
+ url.search = searchParams.toString();
741
+ return url;
742
+ }
744
743
 
745
744
  class Snapshot {
746
745
  constructor(element) {
@@ -3010,7 +3009,7 @@ class FrameController {
3010
3009
  }
3011
3010
  async visit(url) {
3012
3011
  var _a;
3013
- const request = new FetchRequest(this, FetchMethod.get, url, url.searchParams, this.element);
3012
+ const request = new FetchRequest(this, FetchMethod.get, url, new URLSearchParams, this.element);
3014
3013
  (_a = this.currentFetchRequest) === null || _a === void 0 ? void 0 : _a.cancel();
3015
3014
  this.currentFetchRequest = request;
3016
3015
  return new Promise(resolve => {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Turbo 7.1.0-rc.3
2
+ Turbo 7.1.0
3
3
  Copyright © 2021 Basecamp, LLC
4
4
  */
5
5
  (function (global, factory) {
@@ -411,9 +411,7 @@ Copyright © 2021 Basecamp, LLC
411
411
  this.method = method;
412
412
  this.headers = this.defaultHeaders;
413
413
  this.body = body;
414
- this.url = this.isIdempotent ?
415
- mergeFormDataEntries(new URL(location.href), this.entries) :
416
- location;
414
+ this.url = location;
417
415
  this.target = target;
418
416
  }
419
417
  get location() {
@@ -500,16 +498,6 @@ Copyright © 2021 Basecamp, LLC
500
498
  await requestInterception;
501
499
  }
502
500
  }
503
- function mergeFormDataEntries(url, entries) {
504
- const searchParams = new URLSearchParams;
505
- for (const [name, value] of entries) {
506
- if (value instanceof File)
507
- continue;
508
- searchParams.append(name, value);
509
- }
510
- url.search = searchParams.toString();
511
- return url;
512
- }
513
501
 
514
502
  class AppearanceObserver {
515
503
  constructor(delegate, element) {
@@ -603,6 +591,10 @@ Copyright © 2021 Basecamp, LLC
603
591
  this.formElement = formElement;
604
592
  this.submitter = submitter;
605
593
  this.formData = buildFormData(formElement, submitter);
594
+ this.location = expandURL(this.action);
595
+ if (this.method == FetchMethod.get) {
596
+ mergeFormDataEntries(this.location, [...this.body.entries()]);
597
+ }
606
598
  this.fetchRequest = new FetchRequest(this, this.method, this.location, this.body, this.formElement);
607
599
  this.mustRedirect = mustRedirect;
608
600
  }
@@ -619,9 +611,6 @@ Copyright © 2021 Basecamp, LLC
619
611
  const formElementAction = typeof this.formElement.action === 'string' ? this.formElement.action : null;
620
612
  return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formaction")) || this.formElement.getAttribute("action") || formElementAction || "";
621
613
  }
622
- get location() {
623
- return expandURL(this.action);
624
- }
625
614
  get body() {
626
615
  if (this.enctype == FormEnctype.urlEncoded || this.method == FetchMethod.get) {
627
616
  return new URLSearchParams(this.stringFormData);
@@ -747,6 +736,16 @@ Copyright © 2021 Basecamp, LLC
747
736
  function responseSucceededWithoutRedirect(response) {
748
737
  return response.statusCode == 200 && !response.redirected;
749
738
  }
739
+ function mergeFormDataEntries(url, entries) {
740
+ const searchParams = new URLSearchParams;
741
+ for (const [name, value] of entries) {
742
+ if (value instanceof File)
743
+ continue;
744
+ searchParams.append(name, value);
745
+ }
746
+ url.search = searchParams.toString();
747
+ return url;
748
+ }
750
749
 
751
750
  class Snapshot {
752
751
  constructor(element) {
@@ -3016,7 +3015,7 @@ Copyright © 2021 Basecamp, LLC
3016
3015
  }
3017
3016
  async visit(url) {
3018
3017
  var _a;
3019
- const request = new FetchRequest(this, FetchMethod.get, url, url.searchParams, this.element);
3018
+ const request = new FetchRequest(this, FetchMethod.get, url, new URLSearchParams, this.element);
3020
3019
  (_a = this.currentFetchRequest) === null || _a === void 0 ? void 0 : _a.cancel();
3021
3020
  this.currentFetchRequest = request;
3022
3021
  return new Promise(resolve => {
@@ -32,6 +32,7 @@ export declare class FormSubmission {
32
32
  readonly formElement: HTMLFormElement;
33
33
  readonly submitter?: HTMLElement;
34
34
  readonly formData: FormData;
35
+ readonly location: URL;
35
36
  readonly fetchRequest: FetchRequest;
36
37
  readonly mustRedirect: boolean;
37
38
  state: FormSubmissionState;
@@ -40,7 +41,6 @@ export declare class FormSubmission {
40
41
  constructor(delegate: FormSubmissionDelegate, formElement: HTMLFormElement, submitter?: HTMLElement, mustRedirect?: boolean);
41
42
  get method(): FetchMethod;
42
43
  get action(): string;
43
- get location(): URL;
44
44
  get body(): FormData;
45
45
  get enctype(): FormEnctype;
46
46
  get isIdempotent(): boolean;
@@ -3,6 +3,7 @@ export declare class FrameTests extends TurboDriveTestCase {
3
3
  setup(): Promise<void>;
4
4
  "test navigating a frame a second time does not leak event listeners"(): Promise<void>;
5
5
  "test following a link preserves the current <turbo-frame> element's attributes"(): Promise<void>;
6
+ "test following a link sets the frame element's [src]"(): Promise<void>;
6
7
  "test a frame whose src references itself does not infinitely loop"(): Promise<void>;
7
8
  "test following a link driving a frame toggles the [aria-busy=true] attribute"(): Promise<void>;
8
9
  "test following a link to a page without a matching frame results in an empty frame"(): Promise<void>;
@@ -6,6 +6,7 @@ export declare class NavigationTests extends TurboDriveTestCase {
6
6
  "test after loading the page"(): Promise<void>;
7
7
  "test following a same-origin unannotated link"(): Promise<void>;
8
8
  "test following a same-origin unannotated custom element link"(): Promise<void>;
9
+ "test following a same-origin unannotated link with search params"(): Promise<void>;
9
10
  "test following a same-origin unannotated form[method=GET]"(): Promise<void>;
10
11
  "test following a same-origin data-turbo-action=replace link"(): Promise<void>;
11
12
  "test following a same-origin GET form[data-turbo-action=replace]"(): Promise<void>;
@@ -7,6 +7,7 @@ export declare class VisitTests extends TurboDriveTestCase {
7
7
  "test canceling a before-visit event prevents navigation"(): Promise<void>;
8
8
  "test navigation by history is not cancelable"(): Promise<void>;
9
9
  "test turbo:before-fetch-request event.detail"(): Promise<void>;
10
+ "test turbo:before-fetch-request event.detail encodes searchParams"(): Promise<void>;
10
11
  "test turbo:before-fetch-response open new site"(): Promise<void>;
11
12
  "test cache does not override response after redirect"(): Promise<void>;
12
13
  visitLocation(location: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwired/turbo",
3
- "version": "7.1.0-rc.3",
3
+ "version": "7.1.0",
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",