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 1950a13
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 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 @@ -4979,6 +4979,8 @@ function isBodyInit(body) {
return body instanceof FormData || body instanceof URLSearchParams;
}

window.Turbo = Turbo$1;

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

var adapters = {
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 @@ -8,4 +8,6 @@ export { cable }

import { encodeMethodIntoRequestBody } from "./fetch_requests"

window.Turbo = Turbo

addEventListener("turbo:before-fetch-request", encodeMethodIntoRequestBody)
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"
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ hasown@^2.0.0:
dependencies:
function-bind "^1.1.2"

"idiomorph@git+https://github.com/basecamp/idiomorph.git#rollout-build":
"idiomorph@https://github.com/basecamp/idiomorph#rollout-build":
version "0.0.8"
resolved "git+https://github.com/basecamp/idiomorph.git#e906820368e4c9c52489a3336b8c3826b1bf6de5"
resolved "https://github.com/basecamp/idiomorph#e906820368e4c9c52489a3336b8c3826b1bf6de5"

is-core-module@^2.13.0:
version "2.13.1"
Expand Down

0 comments on commit 1950a13

Please sign in to comment.