@@ -78,7 +78,7 @@ class ColorPicker {
78
78
this . #uiManager = editor ?. _uiManager || uiManager ;
79
79
this . #eventBus = this . #uiManager. _eventBus ;
80
80
this . #defaultColor =
81
- editor ?. color ||
81
+ editor ?. color ?. toUpperCase ( ) ||
82
82
this . #uiManager?. highlightColors . values ( ) . next ( ) . value ||
83
83
"#FFFF98" ;
84
84
@@ -96,22 +96,25 @@ class ColorPicker {
96
96
button . className = "colorPicker" ;
97
97
button . tabIndex = "0" ;
98
98
button . setAttribute ( "data-l10n-id" , "pdfjs-editor-colorpicker-button" ) ;
99
- button . setAttribute ( "aria-haspopup" , true ) ;
99
+ button . ariaHasPopup = "true" ;
100
+ if ( this . #editor) {
101
+ button . ariaControls = `${ this . #editor. id } _colorpicker_dropdown` ;
102
+ }
100
103
const signal = this . #uiManager. _signal ;
101
104
button . addEventListener ( "click" , this . #openDropdown. bind ( this ) , { signal } ) ;
102
105
button . addEventListener ( "keydown" , this . #keyDown. bind ( this ) , { signal } ) ;
103
106
const swatch = ( this . #buttonSwatch = document . createElement ( "span" ) ) ;
104
107
swatch . className = "swatch" ;
105
- swatch . setAttribute ( "aria-hidden" , true ) ;
108
+ swatch . ariaHidden = " true" ;
106
109
swatch . style . backgroundColor = this . #defaultColor;
107
110
button . append ( swatch ) ;
108
111
return button ;
109
112
}
110
113
111
114
renderMainDropdown ( ) {
112
115
const dropdown = ( this . #dropdown = this . #getDropdownRoot( ) ) ;
113
- dropdown . setAttribute ( "aria-orientation" , "horizontal" ) ;
114
- dropdown . setAttribute ( "aria-labelledby" , "highlightColorPickerLabel" ) ;
116
+ dropdown . ariaOrientation = "horizontal" ;
117
+ dropdown . ariaLabelledBy = "highlightColorPickerLabel" ;
115
118
116
119
return dropdown ;
117
120
}
@@ -122,9 +125,12 @@ class ColorPicker {
122
125
div . addEventListener ( "contextmenu" , noContextMenu , { signal } ) ;
123
126
div . className = "dropdown" ;
124
127
div . role = "listbox" ;
125
- div . setAttribute ( "aria-multiselectable" , false ) ;
126
- div . setAttribute ( "aria-orientation" , "vertical" ) ;
128
+ div . ariaMultiSelectable = " false" ;
129
+ div . ariaOrientation = "vertical" ;
127
130
div . setAttribute ( "data-l10n-id" , "pdfjs-editor-colorpicker-dropdown" ) ;
131
+ if ( this . #editor) {
132
+ div . id = `${ this . #editor. id } _colorpicker_dropdown` ;
133
+ }
128
134
for ( const [ name , color ] of this . #uiManager. highlightColors ) {
129
135
const button = document . createElement ( "button" ) ;
130
136
button . tabIndex = "0" ;
@@ -136,7 +142,7 @@ class ColorPicker {
136
142
button . append ( swatch ) ;
137
143
swatch . className = "swatch" ;
138
144
swatch . style . backgroundColor = color ;
139
- button . setAttribute ( "aria-selected" , color === this . #defaultColor) ;
145
+ button . ariaSelected = color === this . #defaultColor;
140
146
button . addEventListener ( "click" , this . #colorSelect. bind ( this , color ) , {
141
147
signal,
142
148
} ) ;
@@ -231,6 +237,7 @@ class ColorPicker {
231
237
signal : this . #uiManager. combinedSignal ( this . #openDropdownAC) ,
232
238
} ) ;
233
239
}
240
+ this . #button. ariaExpanded = "true" ;
234
241
if ( this . #dropdown) {
235
242
this . #dropdown. classList . remove ( "hidden" ) ;
236
243
return ;
@@ -248,6 +255,7 @@ class ColorPicker {
248
255
249
256
hideDropdown ( ) {
250
257
this . #dropdown?. classList . add ( "hidden" ) ;
258
+ this . #button. ariaExpanded = "false" ;
251
259
this . #openDropdownAC?. abort ( ) ;
252
260
this . #openDropdownAC = null ;
253
261
}
@@ -283,7 +291,7 @@ class ColorPicker {
283
291
284
292
const i = this . #uiManager. highlightColors . values ( ) ;
285
293
for ( const child of this . #dropdown. children ) {
286
- child . setAttribute ( "aria-selected" , i . next ( ) . value === color ) ;
294
+ child . ariaSelected = i . next ( ) . value === color . toUpperCase ( ) ;
287
295
}
288
296
}
289
297
0 commit comments