Skip to content

Commit d49c814

Browse files
committed
Unify #setDirection and #setLanguage
Append the `#setDirection` implementation to the existing `#setLanguage` private method. Use `expect` rather than `assert` in the accompanying test coverage. Remove the `nextEventNamed("turbo:load")` test synchronization in favor of Playwright's underlying assertion retries.
1 parent 5b8c49d commit d49c814

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

src/core/drive/page_renderer.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export class PageRenderer extends Renderer {
3030

3131
async prepareToRender() {
3232
this.#setLanguage()
33-
this.#setDirection()
3433
await this.mergeHead()
3534
}
3635

@@ -61,19 +60,13 @@ export class PageRenderer extends Renderer {
6160

6261
#setLanguage() {
6362
const { documentElement } = this.currentSnapshot
64-
const { lang } = this.newSnapshot
63+
const { dir, lang } = this.newSnapshot
6564

6665
if (lang) {
6766
documentElement.setAttribute("lang", lang)
6867
} else {
6968
documentElement.removeAttribute("lang")
7069
}
71-
}
72-
73-
#setDirection() {
74-
const { documentElement } = this.currentSnapshot
75-
const { dir } = this.newSnapshot
76-
7770
if (dir) {
7871
documentElement.setAttribute("dir", dir)
7972
} else {

src/tests/fixtures/dir_rtl.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!doctype html>
22
<html dir="rtl">
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>Turbo</title>
6-
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
7-
<script src="/src/tests/fixtures/test.js"></script>
8-
</head>
9-
<body>
10-
<h1>html[dir="rtl"]</h1>
11-
</body>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Turbo</title>
6+
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
7+
<script src="/src/tests/fixtures/test.js"></script>
8+
</head>
9+
<body>
10+
<h1>html[dir="rtl"]</h1>
11+
</body>
1212
</html>

src/tests/functional/rendering_tests.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,8 @@ test("changes the html[lang] attribute", async ({ page }) => {
203203

204204
test("changes the html[dir] attribute", async ({ page }) => {
205205
await page.click("#dir-rtl")
206-
await nextEventNamed(page, "turbo:load")
207206

208-
assert.equal(await page.getAttribute("html", "dir"), "rtl")
207+
await expect(page.locator("html")).toHaveAttribute("dir", "rtl")
209208
})
210209

211210
test("accumulates script elements in head", async ({ page }) => {

0 commit comments

Comments
 (0)