aboutsummaryrefslogblamecommitdiffstats
path: root/tests/test_utils/to_swc.rs
blob: 1d25f4787ebcba33f157f4617b993ae4c7285dbb (plain) (tree)
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714









































































































































































































































































































































































































































































































































































































































































































































                                                                                                                              
extern crate swc_common;
extern crate swc_ecma_ast;
use crate::test_utils::hast;
use crate::test_utils::swc::{parse_esm_to_tree, parse_expression_to_tree};
use core::str;
use micromark::{unist::Position, MdxExpressionKind};

/// Result.
#[derive(Debug, PartialEq, Eq)]
pub struct Program {
    /// JS AST.
    pub module: swc_ecma_ast::Module,
    /// Comments relating to AST.
    pub comments: Vec<swc_common::comments::Comment>,
}

/// Whether we’re in HTML or SVG.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Space {
    Html,
    Svg,
}

#[derive(Debug)]
struct Context {
    /// Whether we’re in HTML or SVG.
    ///
    /// Not used yet, likely useful in the future.
    space: Space,
    /// Comments we gather.
    comments: Vec<swc_common::comments::Comment>,
    /// Declarations and stuff.
    esm: Vec<swc_ecma_ast::ModuleItem>,
}

impl Context {
    /// Create a new context.
    fn new() -> Context {
        Context {
            space: Space::Html,
            comments: vec![],
            esm: vec![],
        }
    }
}

#[allow(dead_code)]
pub fn to_swc(tree: &hast::Node) -> Result<Program, String> {
    let mut context = Context::new();
    let expr = match one(&mut context, tree)? {
        Some(swc_ecma_ast::JSXElementChild::JSXFragment(x)) => {
            Some(swc_ecma_ast::Expr::JSXFragment(x))
        }
        Some(swc_ecma_ast::JSXElementChild::JSXElement(x)) => {
            Some(swc_ecma_ast::Expr::JSXElement(x))
        }
        Some(child) => Some(swc_ecma_ast::Expr::JSXFragment(create_fragment(
            vec![child],
            tree,
        ))),
        None => None,
    };

    // Add the ESM.
    let mut module = swc_ecma_ast::Module {
        shebang: None,
        body: context.esm,
        span: position_to_span(tree.position()),
    };

    // We have some content, wrap it.
    if let Some(expr) = expr {
        module
            .body
            .push(swc_ecma_ast::ModuleItem::Stmt(swc_ecma_ast::Stmt::Expr(
                swc_ecma_ast::ExprStmt {
                    expr: Box::new(expr),
                    span: swc_common::DUMMY_SP,
                },
            )));
    }

    Ok(Program {
        module,
        comments: context.comments,
    })
}

/// Transform one node.
fn one(
    context: &mut Context,
    node: &hast::Node,
) -> Result<Option<swc_ecma_ast::JSXElementChild>, String> {
    let value = match node {
        hast::Node::Comment(x) => Some(transform_comment(context, node, x)),
        hast::Node::Element(x) => transform_element(context, node, x)?,
        hast::Node::MdxJsxElement(x) => transform_mdx_jsx_element(context, node, x)?,
        hast::Node::MdxExpression(x) => transform_mdx_expression(context, node, x)?,
        hast::Node::MdxjsEsm(x) => transform_mdxjs_esm(context, node, x)?,
        hast::Node::Root(x) => transform_root(context, node, x)?,
        hast::Node::Text(x) => transform_text(context, node, x),
        // Ignore:
        hast::Node::Doctype(_) => None,
    };
    Ok(value)
}

/// Transform children of `parent`.
fn all(
    context: &mut Context,
    parent: &hast::Node,
) -> Result<Vec<swc_ecma_ast::JSXElementChild>, String> {
    let mut result = vec![];
    if let Some(children) = parent.children() {
        let mut index = 0;
        while index < children.len() {
            let child = &children[index];
            // To do: remove line endings between table elements?
            // <https://github.com/syntax-tree/hast-util-to-estree/blob/6c45f166d106ea3a165c14ec50c35ed190055e65/lib/index.js>
            if let Some(child) = one(context, child)? {
                result.push(child);
            }
            index += 1;
        }
    }

    Ok(result)
}

/// [`Comment`][hast::Comment].
fn transform_comment(
    context: &mut Context,
    node: &hast::Node,
    comment: &hast::Comment,
) -> swc_ecma_ast::JSXElementChild {
    context.comments.push(swc_common::comments::Comment {
        kind: swc_common::comments::CommentKind::Block,
        text: comment.value.clone().into(),
        span: position_to_span(node.position()),
    });

    // Might be useless.
    // Might be useful when transforming to acorn/babel later.
    // This is done in the JS version too:
    // <https://github.com/syntax-tree/hast-util-to-estree/blob/6c45f166d106ea3a165c14ec50c35ed190055e65/lib/index.js#L168>
    swc_ecma_ast::JSXElementChild::JSXExprContainer(swc_ecma_ast::JSXExprContainer {
        expr: swc_ecma_ast::JSXExpr::JSXEmptyExpr(swc_ecma_ast::JSXEmptyExpr {
            span: position_to_span(node.position()),
        }),
        span: position_to_span(node.position()),
    })
}

/// [`Element`][hast::Element].
fn transform_element(
    context: &mut Context,
    node: &hast::Node,
    element: &hast::Element,
) -> Result<Option<swc_ecma_ast::JSXElementChild>, String> {
    let space = context.space;

    if space == Space::Html && element.tag_name == "svg" {
        context.space = Space::Svg;
    }

    let children = all(context, node)?;

    context.space = space;

    let mut attrs = vec![];

    let mut index = 0;
    while index < element.properties.len() {
        let prop = &element.properties[index];

        // To do: turn style props into objects.
        let value = match &prop.1 {
            hast::PropertyValue::Boolean(x) => {
                // No value is same as `{true}` / Ignore `false`.
                if *x {
                    None
                } else {
                    index += 1;
                    continue;
                }
            }
            hast::PropertyValue::String(x) => Some(swc_ecma_ast::Lit::Str(swc_ecma_ast::Str {
                value: x.clone().into(),
                span: swc_common::DUMMY_SP,
                raw: None,
            })),
            hast::PropertyValue::CommaSeparated(x) => {
                Some(swc_ecma_ast::Lit::Str(swc_ecma_ast::Str {
                    value: x.join(", ").into(),
                    span: swc_common::DUMMY_SP,
                    raw: None,
                }))
            }
            hast::PropertyValue::SpaceSeparated(x) => {
                Some(swc_ecma_ast::Lit::Str(swc_ecma_ast::Str {
                    value: x.join(" ").into(),
                    span: swc_common::DUMMY_SP,
                    raw: None,
                }))
            }
        };

        // Turn property case into either React-specific case, or HTML
        // attribute case.
        // To do: create a spread if this is an invalid attr name.
        let attr_name = prop_to_attr_name(&prop.0);

        attrs.push(swc_ecma_ast::JSXAttrOrSpread::JSXAttr(
            swc_ecma_ast::JSXAttr {
                name: create_jsx_attr_name(&attr_name),
                value: value.map(swc_ecma_ast::JSXAttrValue::Lit),
                span: swc_common::DUMMY_SP,
            },
        ));

        index += 1;
    }

    Ok(Some(swc_ecma_ast::JSXElementChild::JSXElement(
        create_element(&element.tag_name, attrs, children, node),
    )))
}

/// [`MdxJsxElement`][hast::MdxJsxElement].
fn transform_mdx_jsx_element(
    context: &mut Context,
    node: &hast::Node,
    element: &hast::MdxJsxElement,
) -> Result<Option<swc_ecma_ast::JSXElementChild>, String> {
    let space = context.space;

    if let Some(name) = &element.name {
        if space == Space::Html && name == "svg" {
            context.space = Space::Svg;
        }
    }

    let children = all(context, node)?;

    context.space = space;

    let mut attrs = vec![];
    let mut index = 0;

    while index < element.attributes.len() {
        let attr = match &element.attributes[index] {
            hast::AttributeContent::Property(prop) => {
                let value = match prop.value.as_ref() {
                    Some(hast::AttributeValue::Literal(x)) => {
                        Some(swc_ecma_ast::JSXAttrValue::Lit(swc_ecma_ast::Lit::Str(
                            swc_ecma_ast::Str {
                                value: x.clone().into(),
                                span: swc_common::DUMMY_SP,
                                raw: None,
                            },
                        )))
                    }
                    Some(hast::AttributeValue::Expression(value)) => {
                        Some(swc_ecma_ast::JSXAttrValue::JSXExprContainer(
                            swc_ecma_ast::JSXExprContainer {
                                expr: swc_ecma_ast::JSXExpr::Expr(parse_expression_to_tree(
                                    value,
                                    &MdxExpressionKind::AttributeValueExpression,
                                )?),
                                span: swc_common::DUMMY_SP,
                            },
                        ))
                    }
                    None => None,
                };

                swc_ecma_ast::JSXAttrOrSpread::JSXAttr(swc_ecma_ast::JSXAttr {
                    span: swc_common::DUMMY_SP,
                    name: create_jsx_attr_name(&prop.name),
                    value,
                })
            }
            hast::AttributeContent::Expression(value) => {
                let expr =
                    parse_expression_to_tree(value, &MdxExpressionKind::AttributeExpression)?;
                swc_ecma_ast::JSXAttrOrSpread::SpreadElement(swc_ecma_ast::SpreadElement {
                    dot3_token: swc_common::DUMMY_SP,
                    expr,
                })
            }
        };

        attrs.push(attr);
        index += 1;
    }

    Ok(Some(if let Some(name) = &element.name {
        swc_ecma_ast::JSXElementChild::JSXElement(create_element(name, attrs, children, node))
    } else {
        swc_ecma_ast::JSXElementChild::JSXFragment(create_fragment(children, node))
    }))
}

/// [`MdxExpression`][hast::MdxExpression].
fn transform_mdx_expression(
    _context: &mut Context,
    node: &hast::Node,
    expression: &hast::MdxExpression,
) -> Result<Option<swc_ecma_ast::JSXElementChild>, String> {
    Ok(Some(swc_ecma_ast::JSXElementChild::JSXExprContainer(
        swc_ecma_ast::JSXExprContainer {
            expr: swc_ecma_ast::JSXExpr::Expr(parse_expression_to_tree(
                &expression.value,
                &MdxExpressionKind::Expression,
            )?),
            span: position_to_span(node.position()),
        },
    )))
}

/// [`MdxjsEsm`][hast::MdxjsEsm].
fn transform_mdxjs_esm(
    context: &mut Context,
    _node: &hast::Node,
    esm: &hast::MdxjsEsm,
) -> Result<Option<swc_ecma_ast::JSXElementChild>, String> {
    let mut module = parse_esm_to_tree(&esm.value)?;
    let mut index = 0;

    // To do: check that identifiers are not duplicated across esm blocks.
    while index < module.body.len() {
        if !matches!(module.body[index], swc_ecma_ast::ModuleItem::ModuleDecl(_)) {
            return Err("Unexpected `statement` in code: only import/exports are supported".into());
        }
        index += 1;
    }

    context.esm.append(&mut module.body);
    Ok(None)
}

/// [`Root`][hast::Root].
fn transform_root(
    context: &mut Context,
    node: &hast::Node,
    _root: &hast::Root,
) -> Result<Option<swc_ecma_ast::JSXElementChild>, String> {
    let children = all(context, node)?;
    // To do: remove whitespace?
    // To do: return a single child if there is one?
    Ok(Some(swc_ecma_ast::JSXElementChild::JSXFragment(
        create_fragment(children, node),
    )))
}

/// [`Text`][hast::Text].
fn transform_text(
    _context: &mut Context,
    node: &hast::Node,
    text: &hast::Text,
) -> Option<swc_ecma_ast::JSXElementChild> {
    if text.value.is_empty() {
        None
    } else {
        Some(swc_ecma_ast::JSXElementChild::JSXExprContainer(
            swc_ecma_ast::JSXExprContainer {
                expr: swc_ecma_ast::JSXExpr::Expr(Box::new(swc_ecma_ast::Expr::Lit(
                    swc_ecma_ast::Lit::Str(swc_ecma_ast::Str {
                        value: text.value.clone().into(),
                        span: position_to_span(node.position()),
                        raw: None,
                    }),
                ))),
                span: position_to_span(node.position()),
            },
        ))
    }
}

/// Create an element.
///
/// Creates a void one if there are no children.
fn create_element(
    name: &str,
    attrs: Vec<swc_ecma_ast::JSXAttrOrSpread>,
    children: Vec<swc_ecma_ast::JSXElementChild>,
    node: &hast::Node,
) -> Box<swc_ecma_ast::JSXElement> {
    Box::new(swc_ecma_ast::JSXElement {
        opening: swc_ecma_ast::JSXOpeningElement {
            name: create_jsx_name(name),
            attrs,
            self_closing: children.is_empty(),
            type_args: None,
            span: swc_common::DUMMY_SP,
        },
        closing: if children.is_empty() {
            None
        } else {
            Some(swc_ecma_ast::JSXClosingElement {
                name: create_jsx_name(name),
                span: swc_common::DUMMY_SP,
            })
        },
        children,
        span: position_to_span(node.position()),
    })
}

/// Create a fragment.
fn create_fragment(
    children: Vec<swc_ecma_ast::JSXElementChild>,
    node: &hast::Node,
) -> swc_ecma_ast::JSXFragment {
    swc_ecma_ast::JSXFragment {
        opening: swc_ecma_ast::JSXOpeningFragment {
            span: swc_common::DUMMY_SP,
        },
        closing: swc_ecma_ast::JSXClosingFragment {
            span: swc_common::DUMMY_SP,
        },
        children,
        span: position_to_span(node.position()),
    }
}

/// Create an ident.
fn create_ident(sym: &str) -> swc_ecma_ast::Ident {
    swc_ecma_ast::Ident {
        sym: sym.into(),
        optional: false,
        span: swc_common::DUMMY_SP,
    }
}

/// Create a JSX element name.
fn create_jsx_name(name: &str) -> swc_ecma_ast::JSXElementName {
    match parse_jsx_name(name) {
        // `<a.b.c />`
        // `<a.b />`
        JsxName::Member(parts) => {
            // Always two or more items.
            let mut member = swc_ecma_ast::JSXMemberExpr {
                obj: swc_ecma_ast::JSXObject::Ident(create_ident(parts[0])),
                prop: create_ident(parts[1]),
            };
            let mut index = 2;
            while index < parts.len() {
                member = swc_ecma_ast::JSXMemberExpr {
                    obj: swc_ecma_ast::JSXObject::JSXMemberExpr(Box::new(member)),
                    prop: create_ident(parts[index]),
                };
                index += 1;
            }
            swc_ecma_ast::JSXElementName::JSXMemberExpr(member)
        }
        // `<a:b />`
        JsxName::Namespace(ns, name) => {
            swc_ecma_ast::JSXElementName::JSXNamespacedName(swc_ecma_ast::JSXNamespacedName {
                ns: create_ident(ns),
                name: create_ident(name),
            })
        }
        // `<a />`
        JsxName::Normal(name) => swc_ecma_ast::JSXElementName::Ident(create_ident(name)),
    }
}

/// Create a JSX attribute name.
fn create_jsx_attr_name(name: &str) -> swc_ecma_ast::JSXAttrName {
    match parse_jsx_name(name) {
        JsxName::Member(_) => {
            unreachable!("member expressions in attribute names are not supported")
        }
        // `<a b:c />`
        JsxName::Namespace(ns, name) => {
            swc_ecma_ast::JSXAttrName::JSXNamespacedName(swc_ecma_ast::JSXNamespacedName {
                ns: create_ident(ns),
                name: create_ident(name),
            })
        }
        // `<a b />`
        JsxName::Normal(name) => swc_ecma_ast::JSXAttrName::Ident(create_ident(name)),
    }
}

/// Turn a unist positions into an SWC span.
fn position_to_span(position: Option<&Position>) -> swc_common::Span {
    position.map_or(swc_common::DUMMY_SP, |d| swc_common::Span {
        lo: swc_common::BytePos(d.start.offset as u32),
        hi: swc_common::BytePos(d.end.offset as u32),
        ctxt: swc_common::SyntaxContext::empty(),
    })
}

/// Different kinds of JSX names.
enum JsxName<'a> {
    // `a.b.c`
    Member(Vec<&'a str>),
    // `a:b`
    Namespace(&'a str, &'a str),
    // `a`
    Normal(&'a str),
}

/// Parse a JSX name from a string.
fn parse_jsx_name(name: &str) -> JsxName {
    let bytes = name.as_bytes();
    let mut index = 0;
    let mut start = 0;
    let mut parts = vec![];

    while index < bytes.len() {
        if bytes[index] == b'.' {
            parts.push(&name[start..index]);
            start = index + 1;
        }

        index += 1;
    }

    // `<a.b.c />`
    if !parts.is_empty() {
        parts.push(&name[start..]);
        JsxName::Member(parts)
    }
    // `<a:b />`
    else if let Some(colon) = bytes.iter().position(|d| matches!(d, b':')) {
        JsxName::Namespace(&name[0..colon], &name[(colon + 1)..])
    }
    // `<a />`
    else {
        JsxName::Normal(name)
    }
}

/// Turn a hast property into something that particularly React understands.
fn prop_to_attr_name(prop: &str) -> String {
    // Arbitrary data props, kebab case them.
    if prop.len() > 4 && prop.starts_with("data") {
        // Assume like two dashes maybe?
        let mut result = String::with_capacity(prop.len() + 2);
        let bytes = prop.as_bytes();
        let mut index = 4;
        let mut start = index;
        let mut valid = true;

        result.push_str("data");

        while index < bytes.len() {
            let byte = bytes[index];
            let mut dash = index == 4;

            match byte {
                b'A'..=b'Z' => dash = true,
                b'-' | b'.' | b':' | b'0'..=b'9' | b'a'..=b'z' => {}
                _ => {
                    valid = false;
                    break;
                }
            }

            if dash {
                if start != index {
                    result.push_str(&prop[start..index]);
                }
                result.push('-');
                result.push(byte.to_ascii_lowercase().into());
                start = index + 1;
            }

            index += 1;
        }

        if valid {
            result.push_str(&prop[start..]);
            return result;
        }
    }

    // Look up if prop differs from attribute case.
    // Unknown things are passed through.
    PROP_TO_REACT_PROP
        .iter()
        .find(|d| d.0 == prop)
        .or_else(|| PROP_TO_ATTR_EXCEPTIONS_SHARED.iter().find(|d| d.0 == prop))
        .map(|d| d.1.into())
        .unwrap_or_else(|| prop.into())
}

// Below data is generated with:
//
// Note: there are currently no HTML and SVG specific exceptions.
// If those would start appearing, the logic that uses these lists needs
// To support spaces.
//
// ```js
// import * as x from "property-information";
//
// /** @type {Record<string, string>} */
// let shared = {};
// /** @type {Record<string, string>} */
// let html = {};
// /** @type {Record<string, string>} */
// let svg = {};
//
// Object.keys(x.html.property).forEach((prop) => {
//   let attr = x.html.property[prop].attribute;
//   if (!x.html.property[prop].space && prop !== attr) {
//     html[prop] = attr;
//   }
// });
//
// Object.keys(x.svg.property).forEach((prop) => {
//   let attr = x.svg.property[prop].attribute;
//   if (!x.svg.property[prop].space && prop !== attr) {
//     // Shared.
//     if (prop in html && html[prop] === attr) {
//       shared[prop] = attr;
//       delete html[prop];
//     } else {
//       svg[prop] = attr;
//     }
//   }
// });
//
// /** @type {Array<[string, Array<[string, string]>]>} */
// const all = [
//   ["PROP_TO_REACT_PROP", Object.entries(x.hastToReact)],
//   ["PROP_TO_ATTR_EXCEPTIONS", Object.entries(shared)],
//   ["PROP_TO_ATTR_EXCEPTIONS_HTML", Object.entries(html)],
//   ["PROP_TO_ATTR_EXCEPTIONS_SVG", Object.entries(svg)],
// ];
//
// console.log(
//   all
//     .map((d) => {
//       return `const ${d[0]}: [(&str, &str); ${d[1].length}] = [
// ${d[1].map((d) => `    ("${d[0]}", "${d[1]}")`).join(",\n")}
// ];`;
//     })
//     .join("\n\n")
// );
// ```
const PROP_TO_REACT_PROP: [(&str, &str); 17] = [
    ("classId", "classID"),
    ("dataType", "datatype"),
    ("itemId", "itemID"),
    ("strokeDashArray", "strokeDasharray"),
    ("strokeDashOffset", "strokeDashoffset"),
    ("strokeLineCap", "strokeLinecap"),
    ("strokeLineJoin", "strokeLinejoin"),
    ("strokeMiterLimit", "strokeMiterlimit"),
    ("typeOf", "typeof"),
    ("xLinkActuate", "xlinkActuate"),
    ("xLinkArcRole", "xlinkArcrole"),
    ("xLinkHref", "xlinkHref"),
    ("xLinkRole", "xlinkRole"),
    ("xLinkShow", "xlinkShow"),
    ("xLinkTitle", "xlinkTitle"),
    ("xLinkType", "xlinkType"),
    ("xmlnsXLink", "xmlnsXlink"),
];

const PROP_TO_ATTR_EXCEPTIONS_SHARED: [(&str, &str); 48] = [
    ("ariaActiveDescendant", "aria-activedescendant"),
    ("ariaAtomic", "aria-atomic"),
    ("ariaAutoComplete", "aria-autocomplete"),
    ("ariaBusy", "aria-busy"),
    ("ariaChecked", "aria-checked"),
    ("ariaColCount", "aria-colcount"),
    ("ariaColIndex", "aria-colindex"),
    ("ariaColSpan", "aria-colspan"),
    ("ariaControls", "aria-controls"),
    ("ariaCurrent", "aria-current"),
    ("ariaDescribedBy", "aria-describedby"),
    ("ariaDetails", "aria-details"),
    ("ariaDisabled", "aria-disabled"),
    ("ariaDropEffect", "aria-dropeffect"),
    ("ariaErrorMessage", "aria-errormessage"),
    ("ariaExpanded", "aria-expanded"),
    ("ariaFlowTo", "aria-flowto"),
    ("ariaGrabbed", "aria-grabbed"),
    ("ariaHasPopup", "aria-haspopup"),
    ("ariaHidden", "aria-hidden"),
    ("ariaInvalid", "aria-invalid"),
    ("ariaKeyShortcuts", "aria-keyshortcuts"),
    ("ariaLabel", "aria-label"),
    ("ariaLabelledBy", "aria-labelledby"),
    ("ariaLevel", "aria-level"),
    ("ariaLive", "aria-live"),
    ("ariaModal", "aria-modal"),
    ("ariaMultiLine", "aria-multiline"),
    ("ariaMultiSelectable", "aria-multiselectable"),
    ("ariaOrientation", "aria-orientation"),
    ("ariaOwns", "aria-owns"),
    ("ariaPlaceholder", "aria-placeholder"),
    ("ariaPosInSet", "aria-posinset"),
    ("ariaPressed", "aria-pressed"),
    ("ariaReadOnly", "aria-readonly"),
    ("ariaRelevant", "aria-relevant"),
    ("ariaRequired", "aria-required"),
    ("ariaRoleDescription", "aria-roledescription"),
    ("ariaRowCount", "aria-rowcount"),
    ("ariaRowIndex", "aria-rowindex"),
    ("ariaRowSpan", "aria-rowspan"),
    ("ariaSelected", "aria-selected"),
    ("ariaSetSize", "aria-setsize"),
    ("ariaSort", "aria-sort"),
    ("ariaValueMax", "aria-valuemax"),
    ("ariaValueMin", "aria-valuemin"),
    ("ariaValueNow", "aria-valuenow"),
    ("ariaValueText", "aria-valuetext"),
];