Skip to content

Commit 9102263

Browse files
committed
add aria_div element
1 parent 1ddf237 commit 9102263

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lib/glow/primitives.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,6 +3079,39 @@
30793079
return cfieldset
30803080
}
30813081

3082+
function aria_div(args) { // a form fieldset
3083+
if (!(this instanceof aria_div)) return new aria_div(args) // so aria_div() is like new aria_div()
3084+
var cvs = canvas.get_selected()
3085+
var attrs = {pos:cvs.caption_anchor, aria_live:""}
3086+
3087+
for (a in attrs) {
3088+
if (args[a] !== undefined) {
3089+
attrs[a] = args[a]
3090+
delete args[a]
3091+
}
3092+
}
3093+
3094+
attrs.jdiv = $(`<div aria-live="${attrs.aria_live}">`).appendTo(attrs.pos)
3095+
3096+
var caria_div = { // this structure implements a JavaScript "closure"
3097+
get aria_live() {
3098+
if (attrs.aria_live === undefined) return ""
3099+
return attrs.aria_live
3100+
},
3101+
set aria_live(value) {
3102+
attrs.aria_live = value
3103+
$(attrs.jdiv).attr('aria-live', value)
3104+
},
3105+
get pos() {
3106+
return attrs.jdiv
3107+
},
3108+
set pos(value) {
3109+
throw new Error("Cannot change an aria_div's pos.")
3110+
}
3111+
}
3112+
3113+
return caria_div
3114+
}
30823115

30833116
function checkbox(args) { // a checkbox
30843117
if (!(this instanceof checkbox)) return new checkbox(args) // so checkbox() is like new checkbox()
@@ -3727,6 +3760,7 @@
37273760
winput: winput,
37283761
radio: radio,
37293762
fieldset:fieldset,
3763+
aria_div:aria_div,
37303764
checkbox: checkbox,
37313765
button: button,
37323766
slider: slider,

0 commit comments

Comments
 (0)