Skip to content

Commit d3fff3c

Browse files
committed
Keep code DRY
1 parent cbdeca3 commit d3fff3c

File tree

3 files changed

+4
-32
lines changed

3 files changed

+4
-32
lines changed

packages/controls/src/widget_bool.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,7 @@ class CheckboxView extends DescriptionView {
107107
if (!this.checkbox) {
108108
return; // we might be constructing the parent
109109
}
110-
let tabbable = this.model.get('tabbable');
111-
if (tabbable === true) {
112-
this.el.setAttribute('tabIndex', '0');
113-
} else if (tabbable === false) {
114-
this.el.setAttribute('tabIndex', '-1');
115-
} else if (tabbable === null) {
116-
this.el.removeAttribute('tabIndex');
117-
}
110+
super.updateTabindex();
118111
}
119112

120113
events(): {[e: string]: string} {

packages/controls/src/widget_selection.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,7 @@ class SelectionView extends DescriptionView {
6262
if (!this.listbox) {
6363
return; // we might be constructing the parent
6464
}
65-
let tabbable = this.model.get('tabbable');
66-
if (tabbable === true) {
67-
this.el.setAttribute('tabIndex', '0');
68-
} else if (tabbable === false) {
69-
this.el.setAttribute('tabIndex', '-1');
70-
} else if (tabbable === null) {
71-
this.el.removeAttribute('tabIndex');
72-
}
65+
super.updateTabindex();
7366
}
7467

7568
listbox: HTMLSelectElement;

packages/controls/src/widget_string.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,7 @@ class TextareaView extends DescriptionView {
214214
if (!this.textbox) {
215215
return; // we might be constructing the parent
216216
}
217-
let tabbable = this.model.get('tabbable');
218-
if (tabbable === true) {
219-
this.el.setAttribute('tabIndex', '0');
220-
} else if (tabbable === false) {
221-
this.el.setAttribute('tabIndex', '-1');
222-
} else if (tabbable === null) {
223-
this.el.removeAttribute('tabIndex');
224-
}
217+
super.updateTabindex();
225218
}
226219

227220
events() {
@@ -329,14 +322,7 @@ class TextView extends DescriptionView {
329322
if (!this.textbox) {
330323
return; // we might be constructing the parent
331324
}
332-
let tabbable = this.model.get('tabbable');
333-
if (tabbable === true) {
334-
this.el.setAttribute('tabIndex', '0');
335-
} else if (tabbable === false) {
336-
this.el.setAttribute('tabIndex', '-1');
337-
} else if (tabbable === null) {
338-
this.el.removeAttribute('tabIndex');
339-
}
325+
super.updateTabindex();
340326
}
341327

342328
update(options?: any) {

0 commit comments

Comments
 (0)