@hotwired/turbo 7.2.0-rc.3 → 7.2.1

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.
package/README.md CHANGED
@@ -15,4 +15,4 @@ Read more on [turbo.hotwired.dev](https://turbo.hotwired.dev).
15
15
 
16
16
  Please read [CONTRIBUTING.md](./CONTRIBUTING.md).
17
17
 
18
- © 2021 Basecamp, LLC.
18
+ © 2021 37signals LLC.
@@ -1,6 +1,6 @@
1
1
  /*
2
- Turbo 7.2.0-rc.3
3
- Copyright © 2022 Basecamp, LLC
2
+ Turbo 7.2.0
3
+ Copyright © 2022 37signals LLC
4
4
  */
5
5
  (function () {
6
6
  if (window.Reflect === undefined ||
@@ -2094,8 +2094,8 @@ class FrameRedirector {
2094
2094
  this.linkClickObserver.stop();
2095
2095
  this.formSubmitObserver.stop();
2096
2096
  }
2097
- willFollowLinkToLocation(element) {
2098
- return this.shouldRedirect(element);
2097
+ willFollowLinkToLocation(element, location, event) {
2098
+ return this.shouldRedirect(element) && this.frameAllowsVisitingLocation(element, location, event);
2099
2099
  }
2100
2100
  followedLinkToLocation(element, url) {
2101
2101
  const frame = this.findFrameElement(element);
@@ -2114,6 +2114,14 @@ class FrameRedirector {
2114
2114
  frame.delegate.formSubmitted(element, submitter);
2115
2115
  }
2116
2116
  }
2117
+ frameAllowsVisitingLocation(target, { href: url }, originalEvent) {
2118
+ const event = dispatch("turbo:click", {
2119
+ target,
2120
+ detail: { url, originalEvent },
2121
+ cancelable: true,
2122
+ });
2123
+ return !event.defaultPrevented;
2124
+ }
2117
2125
  shouldSubmit(form, submitter) {
2118
2126
  var _a;
2119
2127
  const action = getAction(form, submitter);
@@ -3342,8 +3350,8 @@ class FrameController {
3342
3350
  if (frame)
3343
3351
  form.setAttribute("data-turbo-frame", frame.id);
3344
3352
  }
3345
- willFollowLinkToLocation(element) {
3346
- return this.shouldInterceptNavigation(element);
3353
+ willFollowLinkToLocation(element, location, event) {
3354
+ return this.shouldInterceptNavigation(element) && this.frameAllowsVisitingLocation(element, location, event);
3347
3355
  }
3348
3356
  followedLinkToLocation(element, location) {
3349
3357
  this.navigateFrame(element, location.href);
@@ -3596,6 +3604,14 @@ class FrameController {
3596
3604
  const root = (_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : "/";
3597
3605
  return expandURL(root);
3598
3606
  }
3607
+ frameAllowsVisitingLocation(target, { href: url }, originalEvent) {
3608
+ const event = dispatch("turbo:click", {
3609
+ target,
3610
+ detail: { url, originalEvent },
3611
+ cancelable: true,
3612
+ });
3613
+ return !event.defaultPrevented;
3614
+ }
3599
3615
  isIgnoringChangesTo(attributeName) {
3600
3616
  return this.ignoredAttributes.has(attributeName);
3601
3617
  }
@@ -1,6 +1,6 @@
1
1
  /*
2
- Turbo 7.2.0-rc.3
3
- Copyright © 2022 Basecamp, LLC
2
+ Turbo 7.2.0
3
+ Copyright © 2022 37signals LLC
4
4
  */
5
5
  (function (global, factory) {
6
6
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -2100,8 +2100,8 @@ Copyright © 2022 Basecamp, LLC
2100
2100
  this.linkClickObserver.stop();
2101
2101
  this.formSubmitObserver.stop();
2102
2102
  }
2103
- willFollowLinkToLocation(element) {
2104
- return this.shouldRedirect(element);
2103
+ willFollowLinkToLocation(element, location, event) {
2104
+ return this.shouldRedirect(element) && this.frameAllowsVisitingLocation(element, location, event);
2105
2105
  }
2106
2106
  followedLinkToLocation(element, url) {
2107
2107
  const frame = this.findFrameElement(element);
@@ -2120,6 +2120,14 @@ Copyright © 2022 Basecamp, LLC
2120
2120
  frame.delegate.formSubmitted(element, submitter);
2121
2121
  }
2122
2122
  }
2123
+ frameAllowsVisitingLocation(target, { href: url }, originalEvent) {
2124
+ const event = dispatch("turbo:click", {
2125
+ target,
2126
+ detail: { url, originalEvent },
2127
+ cancelable: true,
2128
+ });
2129
+ return !event.defaultPrevented;
2130
+ }
2123
2131
  shouldSubmit(form, submitter) {
2124
2132
  var _a;
2125
2133
  const action = getAction(form, submitter);
@@ -3348,8 +3356,8 @@ Copyright © 2022 Basecamp, LLC
3348
3356
  if (frame)
3349
3357
  form.setAttribute("data-turbo-frame", frame.id);
3350
3358
  }
3351
- willFollowLinkToLocation(element) {
3352
- return this.shouldInterceptNavigation(element);
3359
+ willFollowLinkToLocation(element, location, event) {
3360
+ return this.shouldInterceptNavigation(element) && this.frameAllowsVisitingLocation(element, location, event);
3353
3361
  }
3354
3362
  followedLinkToLocation(element, location) {
3355
3363
  this.navigateFrame(element, location.href);
@@ -3602,6 +3610,14 @@ Copyright © 2022 Basecamp, LLC
3602
3610
  const root = (_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : "/";
3603
3611
  return expandURL(root);
3604
3612
  }
3613
+ frameAllowsVisitingLocation(target, { href: url }, originalEvent) {
3614
+ const event = dispatch("turbo:click", {
3615
+ target,
3616
+ detail: { url, originalEvent },
3617
+ cancelable: true,
3618
+ });
3619
+ return !event.defaultPrevented;
3620
+ }
3605
3621
  isIgnoringChangesTo(attributeName) {
3606
3622
  return this.ignoredAttributes.has(attributeName);
3607
3623
  }
@@ -47,7 +47,7 @@ export declare class FrameController implements AppearanceObserverDelegate, Fetc
47
47
  elementAppearedInViewport(_element: Element): void;
48
48
  willSubmitFormLinkToLocation(link: Element): boolean;
49
49
  submittedFormLinkToLocation(link: Element, _location: URL, form: HTMLFormElement): void;
50
- willFollowLinkToLocation(element: Element): boolean;
50
+ willFollowLinkToLocation(element: Element, location: URL, event: MouseEvent): boolean;
51
51
  followedLinkToLocation(element: Element, location: URL): void;
52
52
  willSubmitForm(element: HTMLFormElement, submitter?: HTMLElement): boolean;
53
53
  formSubmitted(element: HTMLFormElement, submitter?: HTMLElement): void;
@@ -89,6 +89,7 @@ export declare class FrameController implements AppearanceObserverDelegate, Fetc
89
89
  set complete(value: boolean);
90
90
  get isActive(): boolean;
91
91
  get rootLocation(): URL;
92
+ private frameAllowsVisitingLocation;
92
93
  private isIgnoringChangesTo;
93
94
  private ignoringChangesToAttribute;
94
95
  private withCurrentNavigationElement;
@@ -9,10 +9,11 @@ export declare class FrameRedirector implements LinkClickObserverDelegate, FormS
9
9
  constructor(session: Session, element: Element);
10
10
  start(): void;
11
11
  stop(): void;
12
- willFollowLinkToLocation(element: Element): boolean;
12
+ willFollowLinkToLocation(element: Element, location: URL, event: MouseEvent): boolean;
13
13
  followedLinkToLocation(element: Element, url: URL): void;
14
14
  willSubmitForm(element: HTMLFormElement, submitter?: HTMLElement): boolean;
15
15
  formSubmitted(element: HTMLFormElement, submitter?: HTMLElement): void;
16
+ private frameAllowsVisitingLocation;
16
17
  private shouldSubmit;
17
18
  private shouldRedirect;
18
19
  private findFrameElement;
@@ -7,6 +7,8 @@ declare type MutationAttributeName = string;
7
7
  declare type MutationAttributeValue = string | null;
8
8
  declare type MutationLog = [MutationAttributeName, Target, MutationAttributeValue];
9
9
  export declare function attributeForSelector(page: Page, selector: string, attributeName: string): Promise<string | null>;
10
+ declare type CancellableEvent = "turbo:click" | "turbo:before-visit";
11
+ export declare function cancelNextEvent(page: Page, eventName: CancellableEvent): Promise<void>;
10
12
  export declare function clickWithoutScrolling(page: Page, selector: string, options?: {}): Promise<false | void>;
11
13
  export declare function clearLocalStorage(page: Page): Promise<void>;
12
14
  export declare function disposeAll(...handles: JSHandle[]): Promise<void[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwired/turbo",
3
- "version": "7.2.0-rc.3",
3
+ "version": "7.2.1",
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",
@@ -20,7 +20,7 @@
20
20
  "browser",
21
21
  "pushstate"
22
22
  ],
23
- "author": "Basecamp, LLC",
23
+ "author": "37signals LLC",
24
24
  "contributors": [
25
25
  "Jeffrey Hardy <jeff@basecamp.com>",
26
26
  "Javan Makhmali <javan@javan.us>",