Skip to content

Commit 996e403

Browse files
refactor: address comments.
1 parent cc7bf83 commit 996e403

4 files changed

Lines changed: 56 additions & 15 deletions

File tree

.oxlintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"nursery": "off"
1010
},
1111
"rules": {
12+
"eqeqeq": "error",
1213
"no-console": "error",
1314
"no-unused-vars": "error",
1415
"no-shadow": "error",

playwright/helpers/app-test-helpers.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ export const runTypecheck = async (page: Page) => {
7777

7878
export const runComponentLint = async (page: Page) => {
7979
await ensurePanelToolsVisible(page, 'component')
80-
await page.getByRole('button', { name: 'Lint' }).first().click()
80+
await page.getByRole('button', { name: 'Component lint' }).click()
8181
}
8282

8383
export const runStylesLint = async (page: Page) => {
8484
await ensurePanelToolsVisible(page, 'styles')
85-
await page.locator('#styles-panel').getByRole('button', { name: 'Lint' }).click()
85+
await page.getByRole('button', { name: 'Styles lint' }).click()
8686
}
8787

8888
export const getActiveStylesEditorLineNumber = async (page: Page) => {
@@ -122,7 +122,7 @@ export const ensureDiagnosticsDrawerOpen = async (page: Page) => {
122122
await toggle.click()
123123
}
124124

125-
await expect(page.locator('#diagnostics-drawer')).toBeVisible()
125+
await expect(page.getByRole('complementary', { name: 'Diagnostics' })).toBeVisible()
126126
}
127127

128128
export const ensureDiagnosticsDrawerClosed = async (page: Page) => {
@@ -135,7 +135,7 @@ export const ensureDiagnosticsDrawerClosed = async (page: Page) => {
135135
await page.getByRole('button', { name: 'Close diagnostics drawer' }).click()
136136
}
137137

138-
await expect(page.locator('#diagnostics-drawer')).toBeHidden()
138+
await expect(page.getByRole('complementary', { name: 'Diagnostics' })).toBeHidden()
139139
}
140140

141141
export const ensureAiChatDrawerOpen = async (page: Page) => {
@@ -146,7 +146,7 @@ export const ensureAiChatDrawerOpen = async (page: Page) => {
146146
await toggle.click()
147147
}
148148

149-
await expect(page.locator('#ai-chat-drawer')).toBeVisible()
149+
await expect(page.getByRole('complementary', { name: 'AI Chat' })).toBeVisible()
150150
}
151151

152152
export const ensureOpenPrDrawerOpen = async (page: Page) => {
@@ -158,7 +158,9 @@ export const ensureOpenPrDrawerOpen = async (page: Page) => {
158158
await toggle.click()
159159
}
160160

161-
await expect(page.locator('#github-pr-drawer')).toBeVisible()
161+
await expect(
162+
page.getByRole('complementary', { name: 'Open Pull Request' }),
163+
).toBeVisible()
162164
}
163165

164166
export const mockRepositoryBranches = async (

src/index.html

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,12 @@ <h2 id="component-header">Component</h2>
399399
<button class="render-button" id="typecheck-button" type="button">
400400
Typecheck
401401
</button>
402-
<button class="render-button" id="lint-component-button" type="button">
402+
<button
403+
class="render-button"
404+
id="lint-component-button"
405+
type="button"
406+
aria-label="Component lint"
407+
>
403408
Lint
404409
</button>
405410
<label>
@@ -494,7 +499,12 @@ <h2 id="styles-header">Styles</h2>
494499
</div>
495500
<div class="panel-header-main-actions">
496501
<div class="controls controls--actions">
497-
<button class="render-button" id="lint-styles-button" type="button">
502+
<button
503+
class="render-button"
504+
id="lint-styles-button"
505+
type="button"
506+
aria-label="Styles lint"
507+
>
498508
Lint
499509
</button>
500510
<label>
@@ -573,9 +583,14 @@ <h2 id="preview-header">Preview</h2>
573583
</div>
574584
</section>
575585

576-
<aside class="diagnostics-drawer" id="diagnostics-drawer" hidden>
586+
<aside
587+
class="diagnostics-drawer"
588+
id="diagnostics-drawer"
589+
aria-labelledby="diagnostics-title"
590+
hidden
591+
>
577592
<div class="diagnostics-drawer__header">
578-
<h2>Diagnostics</h2>
593+
<h2 id="diagnostics-title">Diagnostics</h2>
579594
<button
580595
class="icon-button"
581596
id="diagnostics-close"
@@ -610,9 +625,14 @@ <h3>Styles</h3>
610625
</section>
611626
</aside>
612627

613-
<aside class="ai-chat-drawer" id="ai-chat-drawer" hidden>
628+
<aside
629+
class="ai-chat-drawer"
630+
id="ai-chat-drawer"
631+
aria-labelledby="ai-chat-title"
632+
hidden
633+
>
614634
<div class="ai-chat-drawer__header">
615-
<h2>AI Chat</h2>
635+
<h2 id="ai-chat-title">AI Chat</h2>
616636
<button
617637
class="icon-button"
618638
id="ai-chat-close"
@@ -662,9 +682,14 @@ <h2>AI Chat</h2>
662682
</div>
663683
</aside>
664684

665-
<aside class="github-pr-drawer" id="github-pr-drawer" hidden>
685+
<aside
686+
class="github-pr-drawer"
687+
id="github-pr-drawer"
688+
aria-labelledby="open-pr-title"
689+
hidden
690+
>
666691
<div class="github-pr-drawer__header">
667-
<h2>Open Pull Request</h2>
692+
<h2 id="open-pr-title">Open Pull Request</h2>
668693
<button
669694
class="icon-button"
670695
id="github-pr-close"

src/modules/editor-codemirror.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ export const createCodeMirrorEditor = async ({
119119
onFocus,
120120
}) => {
121121
const runtime = await ensureCodeMirrorRuntime()
122+
const supportsContentAttributesFacet =
123+
typeof runtime.EditorView.contentAttributes?.of === 'function'
122124
const editorColors = {
123125
keyword: 'var(--cm-keyword)',
124126
name: 'var(--cm-name)',
@@ -319,7 +321,7 @@ export const createCodeMirrorEditor = async ({
319321
...runtime.defaultKeymap,
320322
...runtime.historyKeymap,
321323
]),
322-
...(contentAttributes
324+
...(contentAttributes && supportsContentAttributesFacet
323325
? [runtime.EditorView.contentAttributes.of(contentAttributes)]
324326
: []),
325327
languageCompartment.of(resolveLanguageExtension(runtime, language)),
@@ -331,6 +333,17 @@ export const createCodeMirrorEditor = async ({
331333
state,
332334
parent,
333335
})
336+
337+
if (contentAttributes && !supportsContentAttributesFacet) {
338+
for (const [attributeName, attributeValue] of Object.entries(contentAttributes)) {
339+
if (attributeValue === null || attributeValue === undefined) {
340+
view.contentDOM.removeAttribute(attributeName)
341+
} else {
342+
view.contentDOM.setAttribute(attributeName, String(attributeValue))
343+
}
344+
}
345+
}
346+
334347
const toDocumentOffset = (line, column = 1) => {
335348
const normalizedLine = Number.isInteger(line) ? line : Number(line)
336349
const normalizedColumn = Number.isInteger(column) ? column : Number(column)

0 commit comments

Comments
 (0)