/
index.js
186 lines (183 loc) · 5.65 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
const examples = [
{
name: 'Input & Label: Accessible',
html: `<custom-input cid="input-1" label="First Name"></custom-input>`,
renderedHTML: `<custom-input>
#shadow-root (open)
<label for="input-1">First Name</label>
<input id="input-1" type="text" />
</custom-input>`
}, {
name: 'Input Only: Inaccessible',
html: `<label for="input-2" class="custom-label">Last Name</label>
<custom-input cid="input-2"></custom-input>`,
renderedHTML: `<label for="input-2" class="custom-label">Last Name</label>
<custom-input>
#shadow-root (open)
<input id="input-1" type="text" />
</custom-input>`,
}, {
name: 'List with Explicit Roles: Accessible',
html: `<div role="list">
<custom-list-item content="Butter" isexplicit></custom-list-item>
<custom-list-item content="Sugar" isexplicit></custom-list-item>
<custom-list-item content="Eggs" isexplicit></custom-list-item>
</div>`,
renderedHTML: `<div role="list">
<custom-list-item content="Butter" isexplicit>
#shadow-root (open)
<div role="listitem">Butter</div>
</custom-list-item>
<custom-list-item content="Sugar" isexplicit>
#shadow-root (open)
<div role="listitem">Sugar</div>
</custom-list-item>
<custom-list-item content="Eggs" isexplicit>
#shadow-root (open)
<div role="listitem">Eggs</div>
</custom-list-item>
</div>`,
}, {
name: 'List with Implicit Roles: Inaccessible',
html: `<ul>
<custom-list-item content="Flour"></custom-list-item>
<custom-list-item content="Baking Soda"></custom-list-item>
<custom-list-item content="Salt"></custom-list-item>
</ul>`,
renderedHTML: `<ul>
<custom-list-item content="Flour">
#shadow-root (open)
<li>Flour</li>
</custom-list-item>
<custom-list-item content="Baking Soda">
#shadow-root (open)
<li>Baking Soda</li>
</custom-list-item>
<custom-list-item content="Salt">
#shadow-root (open)
<li>Salt</li>
</custom-list-item>
</ul>`,
}, {
name: 'Custom Element with Tab Index -1',
html: `<custom-input cid="input-4" label="Favorite Color" tabindex="-1"></custom-input>`,
renderedHTML: `<custom-input tabindex="-1">
#shadow-root (open)
<label for="input-4">Favorite Color</label>
<input id="input-4" type="text" />
</custom-input>`,
}, {
name: 'Slot Test: Accessible',
html: `<custom-list>
<div role="listitem" slot="items">zumba 1</div>
<div role="listitem" slot="items">zumba 2</div>
<div role="listitem" slot="items">zumba 3</div>
</custom-list>`,
renderedHTML: `<custom-list>
#shadow-root
<div role="list">
<slot name="items">
#div
#div
#div
</slot>
</div>
<div role="listitem" slot="items">zumba 1</div>
<div role="listitem" slot="items">zumba 2</div>
<div role="listitem" slot="items">zumba 3</div>
</custom-list>`,
}, {
name: 'Input Slot Test: Accessible',
html: `<div>
<label for="input-5" class="custom-label">City</label>
<custom-input useslot>
<input type="text" class="slds-input" id="input-5" slot="input-slot"/>
</custom-input>
</div>`,
renderedHTML: `<div>
<label for="input-5" class="custom-label">City</label>
<custom-input>
#shadow-root
<div>
<slot name="input-slot">
#input
</slot>
</div>
<input type="text" class="slds-input" id="input-5" slot="input-slot">
</custom-input>
</div>`,
}, {
name: 'Input w/ Shadow Boundary Slot Test: Inaccessible',
html: `<div>
<label for="input-3" class="custom-label" class="custom-label">State</label>
<input-slot-test>
<custom-input cid="input-3" slot="first-input"></custom-input>
</input-slot-test>
</div>`,
renderedHTML: `<div>
<label for="input-3">State</label>
<input-slot-test>
#shadow-root (open)
<div>
<slot name="first-input">
#custom-input
</slot>
</div>
<custom-input>
#shadow-root (open)
<input id="input-3" type="text" />
</custom-input>
</input-slot-test>
</div>`,
}, {
name: 'List w/ Slot and Shadow Boundary: Accessible',
html: `<custom-list>
<custom-list-item content="Water" isexplicit slot="items"></custom-list-item>
<custom-list-item content="Milk" isexplicit slot="items"></custom-list-item>
<custom-list-item content="Juice" isexplicit slot="items"></custom-list-item>
</custom-list>`,
renderedHTML: `<custom-list>
#shadow-root
<div role="list">
<slot name="items">
#custom-list-item
#custom-list-item
#custom-list-item
</slot>
</div>
<custom-list-item content="Water" isexplicit slot="items">
#shadow-root (open)
<div role="listitem">Water</div>
</custom-list-item>
<custom-list-item content="Milk" isexplicit slot="items">
#shadow-root (open)
<div role="listitem">Water</div>
</custom-list-item>
<custom-list-item content="Juice" isexplicit slot="items">
#shadow-root (open)
<div role="listitem">Juice</div>
</custom-list-item>
</custom-list>`,
}, {
name: 'Button w/ Global HTML Attribute: Inaccessible',
html: `<custom-button aria-checked="true"></custom-button>`,
renderedHTML: ``,
}
]
$(document).ready(() => {
let removeTags = (str) => {
return String(str).replace(/</g, '<').replace(/>/g, '>');
}
for (let i = 0; i < examples.length; i++) {
$('#table-body').append(`<tr id="row-${i}"></tr>`);
let row = $(`#row-${i}`);
row.append(`<th scope="row">${examples[i].name}</th>`);
row.append(`<td>${examples[i].html}</td>`);
row.append(`<td>
<pre><code>${removeTags(examples[i].html)}</code></pre>
</td>`);
row.append(`<td>
<pre><code>${removeTags(examples[i].renderedHTML)}</code></pre>
</td>`);
}
});