diff --git a/.vscode/launch.json b/.vscode/launch.json index e710bda63..e27a81adc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,7 @@ { "type": "node", "request": "launch", - "name": "Turbolinks: Debug browser tests", + "name": "Turbo: Debug browser tests", "cwd": "${workspaceFolder}", "port": 9229, "outputCapture": "std", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 75e1c77c9..2ad22f6af 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ "version": "2.0.0", "tasks": [ { - "label": "Turbolinks: Build dist directory", + "label": "Turbo: Build dist directory", "type": "shell", "command": "yarn build", "group": { @@ -16,9 +16,9 @@ ] }, { - "label": "Turbolinks: Run tests", + "label": "Turbo: Run tests", "type": "shell", - "dependsOn": "Turbolinks: Build dist directory", + "dependsOn": "Turbo: Build dist directory", "command": "yarn test", "group": { "kind": "test", @@ -26,9 +26,9 @@ } }, { - "label": "Turbolinks: Start dev server", + "label": "Turbo: Start dev server", "type": "shell", - "dependsOn": "Turbolinks: Build dist directory", + "dependsOn": "Turbo: Build dist directory", "command": "yarn start", "problemMatcher": [] } diff --git a/package.json b/package.json index 06e88625b..f9b8d4bcc 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,29 @@ { - "name": "turbolinks", - "version": "5.3.0-beta.1", - "description": "Turbolinks makes navigating your web application faster", + "name": "@hotwired/turbo", + "version": "7.0.0-beta.1", + "description": "Turbo makes navigating your web application faster", "module": "dist/index.js", - "main": "dist/turbolinks.js", + "main": "dist/turbo.js", "types": "dist/index.d.ts", "files": [ "dist" ], "repository": { "type": "git", - "url": "git+https://github.com/turbolinks/turbolinks.git" + "url": "git+https://github.com/hotwired/turbo.git" }, "keywords": [ - "turbolinks", + "hotwire", + "turbo", "browser", "pushstate" ], "author": "javan, packagethief, sstephenson", "license": "MIT", "bugs": { - "url": "https://github.com/turbolinks/turbolinks/issues" + "url": "https://github.com/hotwired/turbo/issues" }, - "homepage": "https://github.com/turbolinks/turbolinks#readme", + "homepage": "https://turbo.hotwire.dev", "devDependencies": { "intern": "^4.9.0", "rollup": "^2.9.1", diff --git a/rollup.config.js b/rollup.config.js index 42e7e957c..90fd27d3b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -22,10 +22,10 @@ export default [ { input: "src/umd.ts", output: { - banner: `/*\nTurbolinks ${version}\nCopyright © ${year} Basecamp, LLC\n */`, - file: "dist/turbolinks.js", + banner: `/*\nTurbo ${version}\nCopyright © ${year} Basecamp, LLC\n */`, + file: "dist/turbo.js", format: "umd", - name: "Turbolinks", + name: "Turbo", sourcemap: true }, ...options diff --git a/src/controller.ts b/src/controller.ts index c1a2c21f5..0779d3c0b 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -190,44 +190,44 @@ export class Controller implements NavigatorDelegate { } notifyApplicationAfterClickingLinkToLocation(link: Element, location: Location) { - return dispatch("turbolinks:click", { target: link, data: { url: location.absoluteURL }, cancelable: true }) + return dispatch("turbo:click", { target: link, data: { url: location.absoluteURL }, cancelable: true }) } notifyApplicationBeforeVisitingLocation(location: Location) { - return dispatch("turbolinks:before-visit", { data: { url: location.absoluteURL }, cancelable: true }) + return dispatch("turbo:before-visit", { data: { url: location.absoluteURL }, cancelable: true }) } notifyApplicationAfterVisitingLocation(location: Location) { - return dispatch("turbolinks:visit", { data: { url: location.absoluteURL } }) + return dispatch("turbo:visit", { data: { url: location.absoluteURL } }) } notifyApplicationBeforeCachingSnapshot() { - return dispatch("turbolinks:before-cache") + return dispatch("turbo:before-cache") } notifyApplicationBeforeRender(newBody: HTMLBodyElement) { - return dispatch("turbolinks:before-render", { data: { newBody }}) + return dispatch("turbo:before-render", { data: { newBody }}) } notifyApplicationAfterRender() { - return dispatch("turbolinks:render") + return dispatch("turbo:render") } notifyApplicationAfterPageLoad(timing: TimingData = {}) { - return dispatch("turbolinks:load", { data: { url: this.location.absoluteURL, timing }}) + return dispatch("turbo:load", { data: { url: this.location.absoluteURL, timing }}) } // Private getActionForLink(link: Element): Action { - const action = link.getAttribute("data-turbolinks-action") + const action = link.getAttribute("data-turbo-action") return isAction(action) ? action : "advance" } linkIsVisitable(link: Element) { - const container = closest(link, "[data-turbolinks]") + const container = closest(link, "[data-turbo]") if (container) { - return container.getAttribute("data-turbolinks") != "false" + return container.getAttribute("data-turbo") != "false" } else { return true } diff --git a/src/fetch_request.ts b/src/fetch_request.ts index f90132f2e..193114899 100644 --- a/src/fetch_request.ts +++ b/src/fetch_request.ts @@ -81,7 +81,7 @@ export class FetchRequest { async perform(): Promise { const { fetchOptions } = this - dispatch("turbolinks:before-fetch-request", { data: { fetchOptions } }) + dispatch("turbo:before-fetch-request", { data: { fetchOptions } }) try { this.delegate.requestStarted(this) const response = await fetch(this.url, fetchOptions) @@ -96,7 +96,7 @@ export class FetchRequest { async receive(response: Response): Promise { const fetchResponse = new FetchResponse(response) - const event = dispatch("turbolinks:before-fetch-response", { cancelable: true, data: { fetchResponse } }) + const event = dispatch("turbo:before-fetch-response", { cancelable: true, data: { fetchResponse } }) if (event.defaultPrevented) { this.delegate.requestPreventedHandlingResponse(this, fetchResponse) } else if (fetchResponse.succeeded) { diff --git a/src/form_submission.ts b/src/form_submission.ts index 4207ca043..621a22e22 100644 --- a/src/form_submission.ts +++ b/src/form_submission.ts @@ -84,7 +84,7 @@ export class FormSubmission { requestStarted(request: FetchRequest) { this.state = FormSubmissionState.waiting - dispatch("turbolinks:submit-start", { target: this.formElement, data: { formSubmission: this } }) + dispatch("turbo:submit-start", { target: this.formElement, data: { formSubmission: this } }) this.delegate.formSubmissionStarted(this) } @@ -115,7 +115,7 @@ export class FormSubmission { requestFinished(request: FetchRequest) { this.state = FormSubmissionState.stopped - dispatch("turbolinks:submit-end", { target: this.formElement, data: { formSubmission: this, ...this.result }}) + dispatch("turbo:submit-end", { target: this.formElement, data: { formSubmission: this, ...this.result }}) this.delegate.formSubmissionFinished(this) } diff --git a/src/globals.d.ts b/src/globals.d.ts index 22343ff85..765f96d0c 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -4,5 +4,5 @@ interface Node { } interface Window { - Turbolinks: any + Turbo: any } diff --git a/src/head_details.ts b/src/head_details.ts index 5fe41af71..8063c4dad 100644 --- a/src/head_details.ts +++ b/src/head_details.ts @@ -94,7 +94,7 @@ function elementType(element: Element) { } function elementIsTracked(element: Element) { - return element.getAttribute("data-turbolinks-track") == "reload" + return element.getAttribute("data-turbo-track") == "reload" } function elementIsScript(element: Element) { diff --git a/src/history.ts b/src/history.ts index ab2dac7dc..b20aba322 100644 --- a/src/history.ts +++ b/src/history.ts @@ -54,7 +54,7 @@ export class History { } update(method: HistoryMethod, location: Location, restorationIdentifier = uuid()) { - const state = { turbolinks: { restorationIdentifier } } + const state = { turbo: { restorationIdentifier } } method.call(history, state, "", location.absoluteURL) this.location = location this.restorationIdentifier = restorationIdentifier @@ -76,11 +76,11 @@ export class History { onPopState = (event: PopStateEvent) => { if (this.shouldHandlePopState()) { - const { turbolinks } = event.state || {} - if (turbolinks) { + const { turbo } = event.state || {} + if (turbo) { const location = Location.currentLocation this.location = location - const { restorationIdentifier } = turbolinks + const { restorationIdentifier } = turbo this.restorationIdentifier = restorationIdentifier this.delegate.historyPoppedToLocationWithRestorationIdentifier(location, restorationIdentifier) } diff --git a/src/progress_bar.ts b/src/progress_bar.ts index 6dbcbd8b8..e847516ea 100644 --- a/src/progress_bar.ts +++ b/src/progress_bar.ts @@ -5,7 +5,7 @@ export class ProgressBar { static get defaultCSS() { return unindent` - .turbolinks-progress-bar { + .turbo-progress-bar { position: fixed; display: block; top: 0; @@ -115,7 +115,7 @@ export class ProgressBar { createProgressElement() { const element = document.createElement("div") - element.className = "turbolinks-progress-bar" + element.className = "turbo-progress-bar" return element } } diff --git a/src/renderer.ts b/src/renderer.ts index e8694573f..4bf2484d3 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -23,7 +23,7 @@ export abstract class Renderer { } createScriptElement(element: Element) { - if (element.getAttribute("data-turbolinks-eval") == "false") { + if (element.getAttribute("data-turbo-eval") == "false") { return element } else { const createdScriptElement = document.createElement("script") diff --git a/src/script_warning.ts b/src/script_warning.ts index 6b17ce27a..1c7a9065f 100644 --- a/src/script_warning.ts +++ b/src/script_warning.ts @@ -3,19 +3,19 @@ import { unindent } from "./util" (() => { let element: Element | null = document.currentScript if (!element) return - if (element.hasAttribute("data-turbolinks-suppress-warning")) return + if (element.hasAttribute("data-turbo-suppress-warning")) return while (element = element.parentElement) { if (element == document.body) { return console.warn(unindent` - You are loading Turbolinks from a + diff --git a/src/tests/fixtures/async_script.html b/src/tests/fixtures/async_script.html index 7ba14de2b..9e20ee824 100644 --- a/src/tests/fixtures/async_script.html +++ b/src/tests/fixtures/async_script.html @@ -2,13 +2,13 @@ - Turbolinks + Turbo - +
diff --git a/src/tests/fixtures/body_script.html b/src/tests/fixtures/body_script.html index 77c21076c..24f6b8fec 100644 --- a/src/tests/fixtures/body_script.html +++ b/src/tests/fixtures/body_script.html @@ -3,9 +3,9 @@ Body script - + - +

Body script

diff --git a/src/tests/fixtures/eval_false_script.html b/src/tests/fixtures/eval_false_script.html index e6c5fcb41..0fa8e1d9c 100644 --- a/src/tests/fixtures/eval_false_script.html +++ b/src/tests/fixtures/eval_false_script.html @@ -2,13 +2,13 @@ - data-turbolinks-eval=false script - + data-turbo-eval=false script + -

data-turbolinks-eval=false script

- + diff --git a/src/tests/fixtures/head_script.html b/src/tests/fixtures/head_script.html index 182bcff4b..171dc7e52 100644 --- a/src/tests/fixtures/head_script.html +++ b/src/tests/fixtures/head_script.html @@ -3,7 +3,7 @@ Head script - + + Turbo +

Navigation

Same-origin unannotated link

-

Same-origin data-turbolinks-action=replace link

-

Same-origin data-turbolinks=false link

-

Same-origin unannotated link inside data-turbolinks=false container

-

Same-origin data-turbolinks=true link inside data-turbolinks=false container

+

Same-origin data-turbo-action=replace link

+

Same-origin data-turbo=false link

+

Same-origin unannotated link inside data-turbo=false container

+

Same-origin data-turbo=true link inside data-turbo=false container

Same-origin anchored link

Same-origin link to named anchor

Cross-origin unannotated link

diff --git a/src/tests/fixtures/one.html b/src/tests/fixtures/one.html index 0301596ea..3c9eff183 100644 --- a/src/tests/fixtures/one.html +++ b/src/tests/fixtures/one.html @@ -3,7 +3,7 @@ One - + diff --git a/src/tests/fixtures/permanent_element.html b/src/tests/fixtures/permanent_element.html index 6fcc76865..dd373aa7d 100644 --- a/src/tests/fixtures/permanent_element.html +++ b/src/tests/fixtures/permanent_element.html @@ -2,14 +2,14 @@ - Turbolinks - + Turbo +

Permanent element

-
Permanent element
+
Permanent element
diff --git a/src/tests/fixtures/rendering.html b/src/tests/fixtures/rendering.html index 71bf5833a..234518772 100644 --- a/src/tests/fixtures/rendering.html +++ b/src/tests/fixtures/rendering.html @@ -2,8 +2,8 @@ - Turbolinks - + Turbo + @@ -14,11 +14,11 @@

Rendering

Additional assets

Head script

Body script

-

data-turbolinks-eval=false script

+

data-turbo-eval=false script

Nonexistent link

Visit control: reload

Permanent element

-
Rendering
+
Rendering
diff --git a/src/tests/fixtures/test.js b/src/tests/fixtures/test.js index c20337e93..5a9b8cd69 100644 --- a/src/tests/fixtures/test.js +++ b/src/tests/fixtures/test.js @@ -11,11 +11,11 @@ } })([ - "turbolinks:before-cache", - "turbolinks:before-render", - "turbolinks:before-visit", - "turbolinks:load", - "turbolinks:render", - "turbolinks:request-end", - "turbolinks:visit" + "turbo:before-cache", + "turbo:before-render", + "turbo:before-visit", + "turbo:load", + "turbo:render", + "turbo:request-end", + "turbo:visit" ]) diff --git a/src/tests/fixtures/tracked_asset_change.html b/src/tests/fixtures/tracked_asset_change.html index f07632d83..648672a35 100644 --- a/src/tests/fixtures/tracked_asset_change.html +++ b/src/tests/fixtures/tracked_asset_change.html @@ -3,7 +3,7 @@ Tracked asset change - + diff --git a/src/tests/fixtures/turbo.js b/src/tests/fixtures/turbo.js new file mode 120000 index 000000000..d74890dbc --- /dev/null +++ b/src/tests/fixtures/turbo.js @@ -0,0 +1 @@ +../../../dist/turbo.js \ No newline at end of file diff --git a/src/tests/fixtures/turbo.js.map b/src/tests/fixtures/turbo.js.map new file mode 120000 index 000000000..b43ba5598 --- /dev/null +++ b/src/tests/fixtures/turbo.js.map @@ -0,0 +1 @@ +../../../dist/turbo.js.map \ No newline at end of file diff --git a/src/tests/fixtures/turbolinks.js b/src/tests/fixtures/turbolinks.js deleted file mode 120000 index dbac12fae..000000000 --- a/src/tests/fixtures/turbolinks.js +++ /dev/null @@ -1 +0,0 @@ -../../../dist/turbolinks.js \ No newline at end of file diff --git a/src/tests/fixtures/turbolinks.js.map b/src/tests/fixtures/turbolinks.js.map deleted file mode 120000 index 8ff5dce42..000000000 --- a/src/tests/fixtures/turbolinks.js.map +++ /dev/null @@ -1 +0,0 @@ -../../../dist/turbolinks.js.map \ No newline at end of file diff --git a/src/tests/fixtures/visit.html b/src/tests/fixtures/visit.html index be8f7d550..8f7cffcab 100644 --- a/src/tests/fixtures/visit.html +++ b/src/tests/fixtures/visit.html @@ -2,8 +2,8 @@ - Turbolinks - + Turbo + diff --git a/src/tests/fixtures/visit_control_reload.html b/src/tests/fixtures/visit_control_reload.html index 97cdc83c3..268ea0dbe 100644 --- a/src/tests/fixtures/visit_control_reload.html +++ b/src/tests/fixtures/visit_control_reload.html @@ -3,9 +3,9 @@ Visit control: reload - + - +

Visit control: reload

diff --git a/src/tests/helpers/turbolinks_test_case.ts b/src/tests/helpers/turbo_test_case.ts similarity index 92% rename from src/tests/helpers/turbolinks_test_case.ts rename to src/tests/helpers/turbo_test_case.ts index 7b9604f89..ebf2e7ec2 100644 --- a/src/tests/helpers/turbolinks_test_case.ts +++ b/src/tests/helpers/turbo_test_case.ts @@ -4,7 +4,7 @@ import { Element } from "@theintern/leadfoot" type EventLog = [string, any] -export class TurbolinksTestCase extends BrowserTestCase { +export class TurboTestCase extends BrowserTestCase { eventLogChannel: RemoteChannel = new RemoteChannel(this.remote, "eventLogs") lastBody?: Element @@ -58,7 +58,7 @@ export class TurbolinksTestCase extends BrowserTestCase { get visitAction(): Promise { return this.evaluate(() => { try { - return window.Turbolinks.controller.navigator.currentVisit.action + return window.Turbo.controller.navigator.currentVisit.action } catch (error) { return "load" } diff --git a/src/tests/navigation_tests.ts b/src/tests/navigation_tests.ts index afb41cb32..12ca7e491 100644 --- a/src/tests/navigation_tests.ts +++ b/src/tests/navigation_tests.ts @@ -1,6 +1,6 @@ -import { TurbolinksTestCase } from "./helpers/turbolinks_test_case" +import { TurboTestCase } from "./helpers/turbo_test_case" -export class NavigationTests extends TurbolinksTestCase { +export class NavigationTests extends TurboTestCase { async setup() { await this.goToLocation("/fixtures/navigation.html") } @@ -17,28 +17,28 @@ export class NavigationTests extends TurbolinksTestCase { this.assert.equal(await this.visitAction, "advance") } - async "test following a same-origin data-turbolinks-action=replace link"() { + async "test following a same-origin data-turbo-action=replace link"() { this.clickSelector("#same-origin-replace-link") await this.nextBody this.assert.equal(await this.pathname, "/fixtures/one.html") this.assert.equal(await this.visitAction, "replace") } - async "test following a same-origin data-turbolinks=false link"() { + async "test following a same-origin data-turbo=false link"() { this.clickSelector("#same-origin-false-link") await this.nextBody this.assert.equal(await this.pathname, "/fixtures/one.html") this.assert.equal(await this.visitAction, "load") } - async "test following a same-origin unannotated link inside a data-turbolinks=false container"() { + async "test following a same-origin unannotated link inside a data-turbo=false container"() { this.clickSelector("#same-origin-unannotated-link-inside-false-container") await this.nextBody this.assert.equal(await this.pathname, "/fixtures/one.html") this.assert.equal(await this.visitAction, "load") } - async "test following a same-origin data-turbolinks=true link inside a data-turbolinks=false container"() { + async "test following a same-origin data-turbo=true link inside a data-turbo=false container"() { this.clickSelector("#same-origin-true-link-inside-false-container") await this.nextBody this.assert.equal(await this.pathname, "/fixtures/one.html") diff --git a/src/tests/rendering_tests.ts b/src/tests/rendering_tests.ts index 570b86bf2..f87bf42e4 100644 --- a/src/tests/rendering_tests.ts +++ b/src/tests/rendering_tests.ts @@ -1,29 +1,29 @@ -import { TurbolinksTestCase } from "./helpers/turbolinks_test_case" +import { TurboTestCase } from "./helpers/turbo_test_case" import { Element } from "@theintern/leadfoot" -export class RenderingTests extends TurbolinksTestCase { +export class RenderingTests extends TurboTestCase { async setup() { await this.goToLocation("/fixtures/rendering.html") } async "test triggers before-render and render events"() { this.clickSelector("#same-origin-link") - const { newBody } = await this.nextEventNamed("turbolinks:before-render") + const { newBody } = await this.nextEventNamed("turbo:before-render") const h1 = await this.querySelector("h1") this.assert.equal(await h1.getVisibleText(), "One") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert(await newBody.equals(await this.body)) } async "test triggers before-render and render events for error pages"() { this.clickSelector("#nonexistent-link") - const { newBody } = await this.nextEventNamed("turbolinks:before-render") + const { newBody } = await this.nextEventNamed("turbo:before-render") this.assert.equal(await newBody.getVisibleText(), "404 Not Found: /nonexistent") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert(await newBody.equals(await this.body)) } @@ -34,7 +34,7 @@ export class RenderingTests extends TurbolinksTestCase { this.assert.equal(await this.visitAction, "load") } - async "test reloads when turbolinks-visit-control setting is reload"() { + async "test reloads when turbo-visit-control setting is reload"() { this.clickSelector("#visit-control-reload-link") await this.nextBody this.assert.equal(await this.pathname, "/fixtures/visit_control_reload.html") @@ -76,15 +76,15 @@ export class RenderingTests extends TurbolinksTestCase { this.assert.equal(await this.headScriptEvaluationCount, undefined) this.clickSelector("#head-script-link") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert.equal(await this.headScriptEvaluationCount, 1) this.goBack() - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert.equal(await this.headScriptEvaluationCount, 1) this.clickSelector("#head-script-link") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert.equal(await this.headScriptEvaluationCount, 1) } @@ -92,21 +92,21 @@ export class RenderingTests extends TurbolinksTestCase { this.assert.equal(await this.bodyScriptEvaluationCount, undefined) this.clickSelector("#body-script-link") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert.equal(await this.bodyScriptEvaluationCount, 1) this.goBack() - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert.equal(await this.bodyScriptEvaluationCount, 1) this.clickSelector("#body-script-link") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert.equal(await this.bodyScriptEvaluationCount, 2) } - async "test does not evaluate data-turbolinks-eval=false scripts"() { + async "test does not evaluate data-turbo-eval=false scripts"() { this.clickSelector("#eval-false-script-link") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert.equal(await this.bodyScriptEvaluationCount, undefined) } @@ -115,12 +115,12 @@ export class RenderingTests extends TurbolinksTestCase { this.assert.equal(await permanentElement.getVisibleText(), "Rendering") this.clickSelector("#permanent-element-link") - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert(await permanentElement.equals(await this.permanentElement)) this.assert.equal(await permanentElement.getVisibleText(), "Rendering") this.goBack() - await this.nextEventNamed("turbolinks:render") + await this.nextEventNamed("turbo:render") this.assert(await permanentElement.equals(await this.permanentElement)) } @@ -174,16 +174,16 @@ export class RenderingTests extends TurbolinksTestCase { } async modifyBodyBeforeCaching() { - return this.remote.execute(() => addEventListener("turbolinks:before-cache", function eventListener(event) { - removeEventListener("turbolinks:before-cache", eventListener, false) + return this.remote.execute(() => addEventListener("turbo:before-cache", function eventListener(event) { + removeEventListener("turbo:before-cache", eventListener, false) document.body.innerHTML = "Modified" }, false)) } async beforeCache(callback: (body: HTMLElement) => void) { return this.remote.execute((callback: (body: HTMLElement) => void) => { - addEventListener("turbolinks:before-cache", function eventListener(event) { - removeEventListener("turbolinks:before-cache", eventListener, false) + addEventListener("turbo:before-cache", function eventListener(event) { + removeEventListener("turbo:before-cache", eventListener, false) callback(document.body) }, false) }, [callback]) diff --git a/src/tests/visit_tests.ts b/src/tests/visit_tests.ts index 1f157b0d1..c249eeb5e 100644 --- a/src/tests/visit_tests.ts +++ b/src/tests/visit_tests.ts @@ -1,7 +1,9 @@ -import { TurbolinksTestCase } from "./helpers/turbolinks_test_case" +import { TurboTestCase } from "./helpers/turbo_test_case" import { get } from "http" -export class VisitTests extends TurbolinksTestCase { +declare const Turbo: any + +export class VisitTests extends TurboTestCase { async setup() { this.goToLocation("/fixtures/visit.html") } @@ -14,13 +16,13 @@ export class VisitTests extends TurbolinksTestCase { this.assert.notEqual(urlBeforeVisit, urlAfterVisit) this.assert.equal(await this.visitAction, "advance") - const { url: urlFromBeforeVisitEvent } = await this.nextEventNamed("turbolinks:before-visit") + const { url: urlFromBeforeVisitEvent } = await this.nextEventNamed("turbo:before-visit") this.assert.equal(urlFromBeforeVisitEvent, urlAfterVisit) - const { url: urlFromVisitEvent } = await this.nextEventNamed("turbolinks:visit") + const { url: urlFromVisitEvent } = await this.nextEventNamed("turbo:visit") this.assert.equal(urlFromVisitEvent, urlAfterVisit) - const { timing } = await this.nextEventNamed("turbolinks:load") + const { timing } = await this.nextEventNamed("turbo:load") this.assert.ok(timing) } @@ -68,12 +70,12 @@ export class VisitTests extends TurbolinksTestCase { } async visitLocation(location: string) { - this.remote.execute((location: string) => window.Turbolinks.visit(location), [location]) + this.remote.execute((location: string) => window.Turbo.visit(location), [location]) } async cancelNextVisit() { - this.remote.execute(() => addEventListener("turbolinks:before-visit", function eventListener(event) { - removeEventListener("turbolinks:before-visit", eventListener, false) + this.remote.execute(() => addEventListener("turbo:before-visit", function eventListener(event) { + removeEventListener("turbo:before-visit", eventListener, false) event.preventDefault() }, false)) } diff --git a/src/view.ts b/src/view.ts index 7248cff45..cfb70c5f9 100644 --- a/src/view.ts +++ b/src/view.ts @@ -87,9 +87,9 @@ export class View { markAsPreview(isPreview: boolean | undefined) { if (isPreview) { - this.htmlElement.setAttribute("data-turbolinks-preview", "") + this.htmlElement.setAttribute("data-turbo-preview", "") } else { - this.htmlElement.removeAttribute("data-turbolinks-preview") + this.htmlElement.removeAttribute("data-turbo-preview") } }