Skip to content

Commit

Permalink
"Escape" is a better term than "break out"
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmcconnell committed Feb 2, 2023
1 parent 82748d5 commit 28fb705
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/core/frames/frame_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,25 +427,25 @@ export class FrameController
}

private handleFrameMissingFromResponse(fetchResponse: FetchResponse) {
if (this.responsePermittedToBreakOutOfFrame(fetchResponse)) {
this.warnFrameMissingBreakout(fetchResponse)
if (this.responsePermittedToEscapeFrame(fetchResponse)) {
this.warnResponseEscapingFrame(fetchResponse)
this.visitResponse(fetchResponse.response)
} else {
this.showFrameMissingError()
this.throwFrameMissingException(fetchResponse)
}
}

private responsePermittedToBreakOutOfFrame(fetchResponse: FetchResponse) {
private responsePermittedToEscapeFrame(fetchResponse: FetchResponse) {
const allowedPathsTag = this.element.ownerDocument.querySelector<HTMLMetaElement>(
`meta[name=turbo-frame-breakout-paths]`
`meta[name=turbo-frame-escape-paths]`
)
const allowedPaths = allowedPathsTag?.content?.split(/\s+/) || []

return allowedPaths.includes(fetchResponse.location.pathname)
}

private warnFrameMissingBreakout(fetchResponse: FetchResponse) {
private warnResponseEscapingFrame(fetchResponse: FetchResponse) {
console.warn(this.frameMissingMessage(fetchResponse, "Performing a full-page visit."))
}

Expand All @@ -457,7 +457,7 @@ export class FrameController
throw new TurboFrameMissingError(
this.frameMissingMessage(
fetchResponse,
"To transform the response into a full-page visit, include its path in a turbo-frame-breakout-paths meta tag."
"To transform the response into a full-page visit, include its path in a turbo-frame-escape-paths meta tag."
)
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/tests/fixtures/frames.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Frame</title>
<meta name="turbo-frame-breakout-paths" content="/src/tests/fixtures/frames/breakout_frame.html /somewhere_else">
<meta name="turbo-frame-escape-paths" content="/src/tests/fixtures/frames/escape_frame.html /somewhere_else">

<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
<script src="/src/tests/fixtures/test.js"></script>
Expand Down Expand Up @@ -98,8 +98,8 @@ <h2>Frames: #nested-child</h2>

<turbo-frame id="missing">
<a id="missing-frame-link" href="/src/tests/fixtures/frames/frame.html">Missing frame</a>
<a id="breakout-frame-link" href="/src/tests/fixtures/frames/breakout_frame.html">Missing frame with breakout</a>
<a id="breakout-redirect-link" href="/__turbo/redirect?path=/src/tests/fixtures/frames/breakout_frame.html">Missing frame with breakout (via redirect)</a>
<a id="escape-frame-link" href="/src/tests/fixtures/frames/escape_frame.html">Missing frame with escape</a>
<a id="escape-redirect-link" href="/__turbo/redirect?path=/src/tests/fixtures/frames/escape_frame.html">Missing frame with escape (via redirect)</a>
<a id="missing-page-link" href="/missing.html">404</a>
</turbo-frame>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html>
<head>
<meta charset="utf-8">
<title>Breakout frame</title>
<title>Escape frame</title>
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
</head>
<body>
<h1>Breakout frame</h1>
<h1>Escape frame</h1>
</body>
</html>
20 changes: 10 additions & 10 deletions src/tests/functional/frame_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,35 +187,35 @@ test("failing to follow a link to a page without a matching frame shows an error
assert.match(error!.message, /The response \(404\) did not contain the expected <turbo-frame id="missing">/)
})

test("following a link to a breakoutable page without a matching frame dispatches a turbo:frame-missing event", async ({
test("following a link to an escapeable page without a matching frame dispatches a turbo:frame-missing event", async ({
page,
}) => {
await page.click("#breakout-frame-link")
await page.click("#escape-frame-link")
const { response } = await nextEventOnTarget(page, "missing", "turbo:frame-missing")

assert.equal(200, response.status)
})

test("successfully following a link to a breakoutable page without a matching frame performs a visit", async ({
test("successfully following a link to an escapeable page without a matching frame performs a visit", async ({
page,
}) => {
await page.click("#breakout-frame-link")
await page.click("#escape-frame-link")

await nextEventNamed(page, "turbo:render")

assert.equal(await page.innerText("h1"), "Breakout frame")
assert.equal(pathname(page.url()), "/src/tests/fixtures/frames/breakout_frame.html")
assert.equal(await page.innerText("h1"), "Escape frame")
assert.equal(pathname(page.url()), "/src/tests/fixtures/frames/escape_frame.html")
})

test("successfully following a link via a redirect to a breakoutable page without a matching frame performs a visit", async ({
test("successfully following a link via a redirect to an escapeable page without a matching frame performs a visit", async ({
page,
}) => {
await page.click("#breakout-redirect-link")
await page.click("#escape-redirect-link")

await nextEventNamed(page, "turbo:render")

assert.equal(await page.innerText("h1"), "Breakout frame")
assert.equal(pathname(page.url()), "/src/tests/fixtures/frames/breakout_frame.html")
assert.equal(await page.innerText("h1"), "Escape frame")
assert.equal(pathname(page.url()), "/src/tests/fixtures/frames/escape_frame.html")
})

test("test the turbo:frame-missing event following a link to a page without a matching frame can be handled", async ({
Expand Down

0 comments on commit 28fb705

Please sign in to comment.