Skip to content

Commit 1cfa094

Browse files
committed
Extract LegacyDelegate and ElementInternalsDelegate
Delegate implementation-specific methods and properties to the appropriate delegate. Set the delegate based on the `TrixEditorElement.formAssociated` property.
1 parent 7d3cf36 commit 1cfa094

File tree

3 files changed

+241
-181
lines changed

3 files changed

+241
-181
lines changed

src/test/system/accessibility_test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
import { assert, test, testGroup, triggerEvent } from "test/test_helper"
1+
import { assert, skipIf, test, testGroup, triggerEvent } from "test/test_helper"
2+
import TrixEditorElement from "trix/elements/trix_editor_element"
23

34
testGroup("Accessibility attributes", { template: "editor_default_aria_label" }, () => {
45
test("sets the role to textbox", () => {
56
const editor = document.getElementById("editor-without-labels")
67
assert.equal(editor.getAttribute("role"), "textbox")
78
})
89

9-
test("does not set aria-label when the element has no <label> elements", () => {
10+
skipIf(TrixEditorElement.formAssociated, "does not set aria-label when the element has no <label> elements", () => {
1011
const editor = document.getElementById("editor-without-labels")
1112
assert.equal(editor.hasAttribute("aria-label"), false)
1213
})
1314

14-
test("does not override aria-label when the element declares it", () => {
15+
skipIf(TrixEditorElement.formAssociated, "does not override aria-label when the element declares it", () => {
1516
const editor = document.getElementById("editor-with-aria-label")
1617
assert.equal(editor.getAttribute("aria-label"), "ARIA Label text")
1718
})
1819

19-
test("does not set aria-label when the element declares aria-labelledby", () => {
20+
skipIf(TrixEditorElement.formAssociated, "does not set aria-label when the element declares aria-labelledby", () => {
2021
const editor = document.getElementById("editor-with-aria-labelledby")
2122
assert.equal(editor.hasAttribute("aria-label"), false)
2223
assert.equal(editor.getAttribute("aria-labelledby"), "aria-labelledby-id")
2324
})
2425

25-
test("assigns aria-label to the text of the element's <label> elements", () => {
26+
skipIf(TrixEditorElement.formAssociated, "assigns aria-label to the text of the element's <label> elements", () => {
2627
const editor = document.getElementById("editor-with-labels")
2728
assert.equal(editor.getAttribute("aria-label"), "Label 1 Label 2 Label 3")
2829
})
2930

30-
test("updates the aria-label on focus", () => {
31+
skipIf(TrixEditorElement.formAssociated, "updates the aria-label on focus", () => {
3132
const editor = document.getElementById("editor-with-modified-label")
3233
const label = document.getElementById("modified-label")
3334

src/test/test_helpers/test_helpers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export const testGroup = function (name, options, callback) {
4848
}
4949
}
5050

51+
export const skipIf = function (condition, ...args) {
52+
testIf(!condition, ...args)
53+
}
54+
5155
export const testIf = function (condition, ...args) {
5256
if (condition) {
5357
test(...Array.from(args || []))

0 commit comments

Comments
 (0)