Skip to content

Commit

Permalink
Assign window.Turbo in @hotwired/turbo-rails/index
Browse files Browse the repository at this point in the history
With the changes made in the prior commit to pass CI merged, the fact
that Turbo and Turbo Rails somehow have differing references to `Turbo`
and `window.Turbo`.

This commit reverts the test harness change that sets `window.Turbo`,
and instead assigns that value as part of the
`@hotwired/turbo-rails/index` module:

```diff
-import { Turbo } from "@hotwired/turbo-rails"
-
-window.Turbo = Turbo
+import "@hotwired/turbo-rails"
```
  • Loading branch information
seanpdoyle committed Dec 7, 2023
1 parent da4576f commit 9f153a6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/assets/javascripts/turbo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4810,7 +4810,7 @@ window.Turbo = Turbo;

start();

var turbo_es2017Esm = Object.freeze({
var Turbo$1 = Object.freeze({
__proto__: null,
FetchEnctype: FetchEnctype,
FetchMethod: FetchMethod,
Expand Down Expand Up @@ -4981,6 +4981,8 @@ function isBodyInit(body) {

addEventListener("turbo:before-fetch-request", encodeMethodIntoRequestBody);

window.Turbo = Turbo$1;

var adapters = {
logger: self.console,
WebSocket: self.WebSocket
Expand Down Expand Up @@ -5514,4 +5516,4 @@ var index = Object.freeze({
getConfig: getConfig
});

export { turbo_es2017Esm as Turbo, cable };
export { Turbo$1 as Turbo, cable };
2 changes: 1 addition & 1 deletion app/assets/javascripts/turbo.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/javascripts/turbo.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app/javascript/turbo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export { cable }
import { encodeMethodIntoRequestBody } from "./fetch_requests"

addEventListener("turbo:before-fetch-request", encodeMethodIntoRequestBody)

window.Turbo = Turbo
4 changes: 1 addition & 3 deletions test/dummy/app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import { Turbo } from "@hotwired/turbo-rails"

window.Turbo = Turbo
import "@hotwired/turbo-rails"

0 comments on commit 9f153a6

Please sign in to comment.