1#![allow(non_snake_case)]
2
3use events::EventHandler;
4
5use crate::*;
6
7pub(crate) fn element(tag: &'static str) -> HtmlNode {
10    HtmlNode::create_element(tag.into())
11}
12
13pub(crate) fn svg_element(tag: &'static str) -> HtmlNode {
15    HtmlNode::create_element_ns("http://www.w3.org/2000/svg", tag.into())
16}
17
18pub struct CustomElement(HtmlNode);
20
21pub fn custom_element(tag: &'static str) -> CustomElement {
23    CustomElement(element(tag))
24}
25
26impl From<CustomElement> for View {
27    fn from(el: CustomElement) -> Self {
28        View::from_node(el.0)
29    }
30}
31
32impl AsHtmlNode for CustomElement {
33    fn as_html_node(&mut self) -> &mut HtmlNode {
34        &mut self.0
35    }
36}
37
38impl GlobalProps for CustomElement {}
39impl HtmlGlobalAttributes for CustomElement {}
40
41macro_rules! impl_attribute {
42    ($(#[$attr:meta])* $v:vis $ident:ident: $ty:ty) => {
43        impl_attribute!($(#[$attr])* $v $ident (stringify!($ident)): $ty);
44    };
45    ($(#[$attr:meta])* $v:vis $ident:ident ($name:expr): $ty:ty) => {
46        $(#[$attr])*
47        $v fn $ident(mut self, value: $ty) -> Self {
48            self.set_attribute($name, value.into());
49            self
50        }
51    }
52}
53
54macro_rules! impl_attributes {
55    ($(
56        $(#[$attr:meta])*
57        $v:vis $ident:ident $(($name:literal))?: $ty:ty,
58    )*) => {
59        $(
60            impl_attribute!($(#[$attr])* $v $ident $(($name))*: $ty);
61        )*
62    };
63}
64
65macro_rules! impl_element {
66    (
67        $(#[$attr:meta])*
68        $name:ident {
69            $(
70                $(#[$prop_attr:meta])*
71                $prop:ident $(($prop_name:literal))?: $ty:ty,
72            )*
73        }
74    ) => {
75        impl_element!($(#[$attr])* $name (stringify!($name)) {
76            $(
77                $(#[$prop_attr])*
78                $prop $(($prop_name))*: $ty,
79            )*
80        });
81    };
82    (
83        $(#[$attr:meta])*
84        $name:ident ($tag:expr) {
85            $(
86                $(#[$prop_attr:meta])*
87                $prop:ident $(($prop_name:literal))?: $ty:ty,
88            )*
89        }
90    ) => {
91        paste::paste! {
92            #[doc = "The `<" $name ">` HTML element. This can be created by calling [`" $name "()`]."]
93            pub struct [<Html $name:camel>] (HtmlNode);
94
95            #[doc = "Create a `<" $name ">` element."]
96            #[doc = ""]
97            $(#[$attr])*
98            pub fn $name() -> [<Html $name:camel>] {
99                [<Html $name:camel>](element($tag))
100            }
101
102            impl From<[<Html $name:camel>]> for View {
103                fn from(el: [<Html $name:camel>]) -> Self {
104                    View::from_node(el.0)
105                }
106            }
107
108            impl AsHtmlNode for [<Html $name:camel>] {
109                fn as_html_node(&mut self) -> &mut HtmlNode {
110                    &mut self.0
111                }
112            }
113
114            impl GlobalProps for [<Html $name:camel>] {}
115            impl HtmlGlobalAttributes for [<Html $name:camel>] {}
116
117            #[doc = "Trait that provides attributes for the `<" $name ">` HTML element."]
118            pub trait [<Html $name:camel Attributes>]: SetAttribute + Sized {
119                impl_attributes! {
120                    $(
121                        $(#[$prop_attr])*
122                        $prop $(($prop_name))*: $ty,
123                    )*
124                }
125            }
126
127            impl [<Html $name:camel Attributes>] for [<Html $name:camel>] {}
128        }
129    };
130}
131
132macro_rules! impl_elements {
133    ($(
134        $(#[$attr:meta])*
135        $name:ident $(($tag:expr))? {
136            $(
137                $(#[$prop_attr:meta])*
138                $prop:ident $(($prop_name:literal))?: $ty:ty,
139            )*
140        },
141    )*) => {
142        $(
143            impl_element!($(#[$attr])* $name $(($tag))* {
144                $(
145                    $(#[$prop_attr])*
146                    $prop $(($prop_name))*: $ty,
147                )*
148            });
149        )*
150        pub mod html_attributes {
152            paste::paste! {
153                pub use super::{$([<Html $name:camel Attributes>]),*};
154            }
155        }
156    };
157}
158
159macro_rules! impl_svg_element {
160    (
161        $(#[$attr:meta])*
162        $name:ident {
163            $(
164                $(#[$prop_attr:meta])*
165                $prop:ident $(($prop_name:literal))?: $ty:ty,
166            )*
167        }
168    ) => {
169        impl_svg_element!($(#[$attr])* $name (stringify!($name)) {
170            $(
171                $(#[$prop_attr])*
172                $prop $(($prop_name))*: $ty,
173            )*
174        });
175    };
176    (
177        $(#[$attr:meta])*
178        $name:ident ($tag:expr) {
179            $(
180                $(#[$prop_attr:meta])*
181                $prop:ident $(($prop_name:literal))?: $ty:ty,
182            )*
183        }
184    ) => {
185        paste::paste! {
186            #[doc = "The `<" $name ">` SVG element. This can be created by calling [`" $name "()`]."]
187            pub struct [<Svg $name:camel>] (HtmlNode);
188
189            #[doc = "Create a `<" $name ">` element."]
190            #[doc = ""]
191            $(#[$attr])*
192            pub fn $name() -> [<Svg $name:camel>] {
193                [<Svg $name:camel>](svg_element($tag))
194            }
195
196            impl From<[<Svg $name:camel>]> for View {
197                fn from(el: [<Svg $name:camel>]) -> Self {
198                    View::from_node(el.0)
199                }
200            }
201
202            impl AsHtmlNode for [<Svg $name:camel>] {
203                fn as_html_node(&mut self) -> &mut HtmlNode {
204                    &mut self.0
205                }
206            }
207
208            impl GlobalProps for [<Svg $name:camel>] {}
209            impl SvgGlobalAttributes for [<Svg $name:camel>] {}
210
211            #[doc = "Trait that provides attributes for the `<" $name ">` SVG element."]
212            pub trait [<Svg $name:camel Attributes>]: SetAttribute + Sized {
213                impl_attributes! {
214                    $(
215                        $(#[$prop_attr])*
216                        $prop $(($prop_name))*: $ty,
217                    )*
218                }
219            }
220
221            impl [<Svg $name:camel Attributes>] for [<Svg $name:camel>] {}
222        }
223    };
224}
225
226macro_rules! impl_svg_elements {
227    ($(
228        $(#[$attr:meta])*
229        $name:ident $(($tag:expr))? {
230            $(
231                $(#[$prop_attr:meta])*
232                $prop:ident $(($prop_name:literal))?: $ty:ty,
233            )*
234        },
235    )*) => {
236        $(
237            impl_svg_element!($(#[$attr])* $name $(($tag))* {
238                $(
239                    $(#[$prop_attr])*
240                    $prop $(($prop_name))*: $ty,
241                )*
242            });
243        )*
244        pub mod svg_attributes {
246            paste::paste! {
247                pub use super::{$([<Svg $name:camel Attributes>]),*};
248            }
249        }
250    };
251}
252
253pub mod tags {
255    use super::*;
256
257    impl_elements! {
258        a {
262            download: impl Into<StringAttribute>,
263            href: impl Into<StringAttribute>,
264            hreflang: impl Into<StringAttribute>,
265            target: impl Into<StringAttribute>,
266            r#type("type"): impl Into<StringAttribute>,
267            ping: impl Into<StringAttribute>,
268            rel: impl Into<StringAttribute>,
269        },
270        abbr {},
271        address {},
272        area {
273            alt: impl Into<StringAttribute>,
274            coords: impl Into<StringAttribute>,
275            download: impl Into<StringAttribute>,
276            href: impl Into<StringAttribute>,
277            hreflang: impl Into<StringAttribute>,
278            media: impl Into<StringAttribute>,
279            referrerpolicy: impl Into<StringAttribute>,
280            ping: impl Into<StringAttribute>,
281            rel: impl Into<StringAttribute>,
282            shape: impl Into<StringAttribute>,
283            target: impl Into<StringAttribute>,
284            r#type("type"): impl Into<StringAttribute>,
285        },
286        article {},
287        aside {},
288        audio {
289            autoplay: impl Into<MaybeDyn<bool>>,
290            controls: impl Into<MaybeDyn<bool>>,
291            crossorigin: impl Into<StringAttribute>,
292            muted: impl Into<MaybeDyn<bool>>,
293            preload: impl Into<StringAttribute>,
294            src: impl Into<StringAttribute>,
295            r#loop("loop"): impl Into<MaybeDyn<bool>>,
296        },
297        b {},
298        base {
299            href: impl Into<StringAttribute>,
300            target: impl Into<StringAttribute>,
301        },
302        bdi {},
303        bdo {},
304        blockquote {
305            cite: impl Into<StringAttribute>,
306        },
307        body {},
308        br {},
309        button {
313            autofocus: impl Into<MaybeDyn<bool>>,
314            disabled: impl Into<MaybeDyn<bool>>,
315            form: impl Into<StringAttribute>,
316            formaction: impl Into<StringAttribute>,
317            formenctype: impl Into<StringAttribute>,
318            formmethod: impl Into<StringAttribute>,
319            formnovalidate: impl Into<MaybeDyn<bool>>,
320            formtarget: impl Into<StringAttribute>,
321            name: impl Into<StringAttribute>,
322            r#type("type"): impl Into<StringAttribute>,
323            value: impl Into<StringAttribute>,
324        },
325        canvas {
326            height: impl Into<StringAttribute>, width: impl Into<StringAttribute>, },
329        caption {},
330        cite {},
331        code {
332            language: impl Into<StringAttribute>,
333        },
334        col {
335            span: impl Into<StringAttribute>, },
337        colgroup {
338            span: impl Into<StringAttribute>, },
340        data {
341            value: impl Into<StringAttribute>,
342        },
343        datalist {},
344        dd {},
345        del {
346            cite: impl Into<StringAttribute>,
347            datetime: impl Into<StringAttribute>,
348        },
349        details {
350            open: impl Into<MaybeDyn<bool>>,
351        },
352        dfn {},
353        dialog {},
354        div {},
361        dl {},
362        dt {},
363        em {},
364        embed {
365            height: impl Into<StringAttribute>,
366            src: impl Into<StringAttribute>,
367            r#type("type"): impl Into<StringAttribute>,
368            width: impl Into<StringAttribute>, },
370        fieldset {},
371        figcaption {},
372        figure {},
373        footer {},
374        form {
375            acceptcharset: impl Into<StringAttribute>,
376            action: impl Into<StringAttribute>,
377            autocomplete: impl Into<StringAttribute>,
378            enctype: impl Into<StringAttribute>,
379            method: impl Into<StringAttribute>,
380            name: impl Into<StringAttribute>,
381            novalidate: impl Into<MaybeDyn<bool>>,
382            target: impl Into<StringAttribute>,
383        },
384        head {},
385        header {},
386        hgroup {},
387        h1 {},
388        h2 {},
389        h3 {},
390        h4 {},
391        h5 {},
392        h6 {},
393        hr {},
394        html {},
395        i {},
396        iframe {
397            allow: impl Into<StringAttribute>,
398            allowfullscreen: impl Into<MaybeDyn<bool>>,
399            allowpaymentrequest: impl Into<MaybeDyn<bool>>,
400            height: impl Into<StringAttribute>,
401            loading: impl Into<StringAttribute>,
402            name: impl Into<StringAttribute>,
403            referrerpolicy: impl Into<StringAttribute>,
404            sandbox: impl Into<MaybeDyn<bool>>,
405            src: impl Into<StringAttribute>,
406            srcdoc: impl Into<StringAttribute>,
407            width: impl Into<StringAttribute>,
408        },
409        img {
410            alt: impl Into<StringAttribute>,
411            crossorigin: impl Into<StringAttribute>,
412            decoding: impl Into<StringAttribute>,
413            height: impl Into<StringAttribute>,
414            ismap: impl Into<MaybeDyn<bool>>,
415            loading: impl Into<StringAttribute>,
416            referrerpolicy: impl Into<StringAttribute>,
417            sizes: impl Into<StringAttribute>,
418            src: impl Into<StringAttribute>,
419            srcset: impl Into<StringAttribute>,
420            usemap: impl Into<StringAttribute>,
421            width: impl Into<StringAttribute>,
422        },
423        input {
425            accept: impl Into<StringAttribute>,
426            alt: impl Into<StringAttribute>,
427            autocomplete: impl Into<StringAttribute>,
428            autofocus: impl Into<MaybeDyn<bool>>,
429            capture: impl Into<StringAttribute>,
430            checked: impl Into<MaybeDyn<bool>>,
431            directory: impl Into<StringAttribute>,
432            disabled: impl Into<MaybeDyn<bool>>,
433            form: impl Into<StringAttribute>,
434            formaction: impl Into<StringAttribute>,
435            formenctype: impl Into<StringAttribute>,
436            formmethod: impl Into<StringAttribute>,
437            formnovalidate: impl Into<MaybeDyn<bool>>,
438            formtarget: impl Into<StringAttribute>,
439            height: impl Into<StringAttribute>, initial_checked: impl Into<MaybeDyn<bool>>,
441            initial_value: impl Into<StringAttribute>,
442            list: impl Into<StringAttribute>,
443            max: impl Into<StringAttribute>,
444            maxlength: impl Into<StringAttribute>, min: impl Into<StringAttribute>,
446            minlength: impl Into<StringAttribute>, multiple: impl Into<MaybeDyn<bool>>,
448            name: impl Into<StringAttribute>,
449            pattern: impl Into<StringAttribute>,
450            placeholder: impl Into<StringAttribute>,
451            readonly: impl Into<MaybeDyn<bool>>,
452            required: impl Into<MaybeDyn<bool>>,
453            size: impl Into<StringAttribute>, spellcheck: impl Into<MaybeDyn<bool>>,
455            src: impl Into<StringAttribute>,
456            step: impl Into<StringAttribute>,
457            tabindex: impl Into<StringAttribute>, r#type("type"): impl Into<StringAttribute>,
459            value: impl Into<StringAttribute>,
460            width: impl Into<StringAttribute>, },
462        ins {
463            cite: impl Into<StringAttribute>,
464            datetime: impl Into<StringAttribute>,
465        },
466        kbd {},
467        keygen {},
468        label {
492            form: impl Into<StringAttribute>,
493            r#for("for"): impl Into<StringAttribute>,
494        },
495        legend {},
496        li {
498            value: impl Into<StringAttribute>, },
500        link {
501            r#as("as"): impl Into<StringAttribute>,
502            crossorigin: impl Into<StringAttribute>,
503            href: impl Into<StringAttribute>,
504            hreflang: impl Into<StringAttribute>,
505            media: impl Into<StringAttribute>,
506            rel: impl Into<StringAttribute>,
507            sizes: impl Into<StringAttribute>,
508            title: impl Into<StringAttribute>,
509            r#type("type"): impl Into<StringAttribute>,
510            integrity: impl Into<StringAttribute>,
511        },
512        main {},
513        map {
514            name: impl Into<StringAttribute>,
515        },
516        mark {},
517        menu {},
518        menuitem {},
519        meta {
520            charset: impl Into<StringAttribute>,
521            content: impl Into<StringAttribute>,
522            http_equiv("http-equiv"): impl Into<StringAttribute>,
523            name: impl Into<StringAttribute>,
524        },
525        meter {
526            value: impl Into<StringAttribute>, min: impl Into<StringAttribute>, max: impl Into<StringAttribute>, low: impl Into<StringAttribute>, high: impl Into<StringAttribute>, optimum: impl Into<StringAttribute>, form: impl Into<StringAttribute>,
533        },
534        nav {},
535        noscript {},
536        object {
537            data: impl Into<StringAttribute>,
538            form: impl Into<StringAttribute>,
539            height: impl Into<StringAttribute>, name: impl Into<StringAttribute>,
541            r#type("type"): impl Into<StringAttribute>,
542            typemustmatch: impl Into<MaybeDyn<bool>>,
543            usemap: impl Into<StringAttribute>,
544            width: impl Into<StringAttribute>,
545        },
546        ol {
548            reversed: impl Into<MaybeDyn<bool>>,
549            start: impl Into<StringAttribute>, r#type("type"): impl Into<StringAttribute>,
551        },
552        optgroup {
553            disabled: impl Into<MaybeDyn<bool>>,
554            label: impl Into<StringAttribute>,
555        },
556        option {
557            disabled: impl Into<MaybeDyn<bool>>,
558            initial_selected: impl Into<MaybeDyn<bool>>,
559            label: impl Into<StringAttribute>,
560            selected: impl Into<MaybeDyn<bool>>,
561            value: impl Into<StringAttribute>,
562        },
563        output {
564            r#for("for"): impl Into<StringAttribute>,
565            form: impl Into<StringAttribute>,
566            name: impl Into<StringAttribute>,
567        },
568        p {},
572        param {
573            name: impl Into<StringAttribute>,
574            value: impl Into<StringAttribute>,
575        },
576        picture {},
577        pre {},
578        progress {
579            value: impl Into<StringAttribute>, max: impl Into<StringAttribute>, },
582        q {
583            cite: impl Into<StringAttribute>,
584        },
585        rp {},
586        rt {},
587        ruby {},
588        s {},
589        samp {},
590        script {
591            r#async: impl Into<MaybeDyn<bool>>,
592            crossorigin: impl Into<StringAttribute>,
593            defer: impl Into<MaybeDyn<bool>>,
594            integrity: impl Into<StringAttribute>,
595            nomodule: impl Into<MaybeDyn<bool>>,
596            nonce: impl Into<StringAttribute>,
597            src: impl Into<StringAttribute>,
598            script: impl Into<StringAttribute>,
599            text: impl Into<StringAttribute>,
600            r#type("type"): impl Into<StringAttribute>,
601        },
602        section {},
603        select {
604            autocomplete: impl Into<StringAttribute>,
605            autofocus: impl Into<MaybeDyn<bool>>,
606            disabled: impl Into<MaybeDyn<bool>>,
607            form: impl Into<StringAttribute>,
608            multiple: impl Into<MaybeDyn<bool>>,
609            name: impl Into<StringAttribute>,
610            required: impl Into<MaybeDyn<bool>>,
611            size: impl Into<StringAttribute>, value: impl Into<StringAttribute>,
613        },
614        small {},
615        source {
616            src: impl Into<StringAttribute>,
617            r#type("type"): impl Into<StringAttribute>,
618        },
619        span {},
621        strong {},
622        style {
623            media: impl Into<StringAttribute>,
624            nonce: impl Into<StringAttribute>,
625            title: impl Into<StringAttribute>,
626            r#type("type"): impl Into<StringAttribute>,
627        },
628        sub {},
629        summary {},
630        sup {},
631        table {},
632        tbody {},
633        td {
634            colspan: impl Into<StringAttribute>, headers: impl Into<StringAttribute>,
636            rowspan: impl Into<StringAttribute>, },
638        template {},
639        textarea {
640            autocomplete: impl Into<StringAttribute>,
641            autofocus: impl Into<MaybeDyn<bool>>,
642            cols: impl Into<StringAttribute>, disabled: impl Into<MaybeDyn<bool>>,
644            form: impl Into<StringAttribute>,
645            initial_value: impl Into<StringAttribute>,
646            maxlength: impl Into<StringAttribute>, minlength: impl Into<StringAttribute>, name: impl Into<StringAttribute>,
649            placeholder: impl Into<StringAttribute>,
650            readonly: impl Into<MaybeDyn<bool>>,
651            required: impl Into<MaybeDyn<bool>>,
652            rows: impl Into<StringAttribute>, spellcheck: impl Into<MaybeDyn<bool>>,
654            r#type("type"): impl Into<StringAttribute>,
655            value: impl Into<StringAttribute>,
656            wrap: impl Into<StringAttribute>,
657        },
658        tfoot {},
659        th {
660            abbr: impl Into<StringAttribute>,
661            colspan: impl Into<StringAttribute>, headers: impl Into<StringAttribute>,
663            rowspan: impl Into<StringAttribute>, scope: impl Into<StringAttribute>,
665        },
666        thead {},
667        time {
668            datetime: impl Into<StringAttribute>,
669        },
670        title {},
671        tr {},
672        track {
673            default: impl Into<MaybeDyn<bool>>,
674            kind: impl Into<StringAttribute>,
675            label: impl Into<StringAttribute>,
676            src: impl Into<StringAttribute>,
677            srclang: impl Into<StringAttribute>,
678        },
679        u {},
680        ul {},
682        var {},
683        video {
684            autoplay: impl Into<MaybeDyn<bool>>,
685            controls: impl Into<MaybeDyn<bool>>,
686            crossorigin: impl Into<StringAttribute>,
687            height: impl Into<StringAttribute>, r#loop("loop"): impl Into<MaybeDyn<bool>>,
689            muted: impl Into<MaybeDyn<bool>>,
690            playsinline: impl Into<MaybeDyn<bool>>,
691            poster: impl Into<StringAttribute>,
692            preload: impl Into<StringAttribute>,
693            src: impl Into<StringAttribute>,
694            width: impl Into<StringAttribute>, },
696        wbr {},
697    }
698
699    impl_svg_elements! {
700        svg {
701            xmlns: impl Into<StringAttribute>,
702        },
703        svg_a("a") {},
704        animate {},
705        animateMotion {},
706        animateTransform {},
707        circle {},
708        clipPath {},
709        defs {},
710        desc {},
711        discard {},
712        ellipse {},
713        feBlend {},
714        feColorMatrix {},
715        feComponentTransfer {},
716        feComposite {},
717        feConvolveMatrix {},
718        feDiffuseLighting {},
719        feDisplacementMap {},
720        feDistantLight {},
721        feDropShadow {},
722        feFlood {},
723        feFuncA {},
724        feFuncB {},
725        feFuncG {},
726        feFuncR {},
727        feGaussianBlur {},
728        feImage {},
729        feMerge {},
730        feMergeNode {},
731        feMorphology {},
732        feOffset {},
733        fePointLight {},
734        feSpecularLighting {},
735        feSpotLight {},
736        feTile {},
737        feTurbulence {},
738        filter {},
739        foreignObject {},
740        g {},
741        hatch {},
742        hatchpath {},
743        image {},
744        line {},
745        linearGradient {},
746        marker {},
747        mask {},
748        metadata {},
749        mpath {},
750        path {},
751        pattern {},
752        polygon {},
753        polyline {},
754        radialGradient {},
755        rect {},
756        svg_script("script") {},
757        set {},
758        stop {},
759        svg_style("style") {},
760        switch {},
761        symbol {},
762        text {},
763        textPath {},
764        svg_title("title") {},
765        tspan {},
766        r#use("use") {},
767        view {},
768    }
769}
770
771pub trait HtmlGlobalAttributes: SetAttribute + Sized {
775    impl_attributes! {
776        accesskey: impl Into<StringAttribute>,
778        autocapitalize: impl Into<StringAttribute>,
780        autofocus: impl Into<MaybeDyn<bool>>,
782        class: impl Into<StringAttribute>,
785        contenteditable: impl Into<StringAttribute>,
789        dir: impl Into<StringAttribute>,
794        draggable: impl Into<StringAttribute>,
798        enterkeyhint: impl Into<StringAttribute>,
800        exportparts: impl Into<StringAttribute>,
802        hidden: impl Into<MaybeDyn<bool>>,
804        id: impl Into<StringAttribute>,
806        inert: impl Into<MaybeDyn<bool>>,
808        inputmode: impl Into<StringAttribute>,
810        is: impl Into<StringAttribute>,
814        itemid: impl Into<StringAttribute>,
816        itemprop: impl Into<StringAttribute>,
818        itemref: impl Into<StringAttribute>,
820        itemscope: impl Into<MaybeDyn<bool>>,
822        itemtype: impl Into<StringAttribute>,
824        lang: impl Into<StringAttribute>,
826        nonce: impl Into<StringAttribute>,
828        part: impl Into<StringAttribute>,
830        popover: impl Into<StringAttribute>,
832        role: impl Into<StringAttribute>,
834        slot: impl Into<StringAttribute>,
836        spellcheck: impl Into<StringAttribute>,
840        style: impl Into<StringAttribute>,
842        tabindex: impl Into<StringAttribute>,
847        title: impl Into<StringAttribute>,
849        translate: impl Into<StringAttribute>,
853        virtualkeyboardpolicy: impl Into<StringAttribute>,
857    }
858}
859
860pub trait SvgGlobalAttributes: SetAttribute + Sized {
865    impl_attributes! {
866        accentHeight("accent-height"): impl Into<StringAttribute>,
867        accumulate: impl Into<StringAttribute>,
868        additive: impl Into<StringAttribute>,
869        alignmentBaseline("alignment-baseline"): impl Into<StringAttribute>,
870        alphabetic: impl Into<StringAttribute>,
871        amplitude: impl Into<StringAttribute>,
872        arabicForm("arabic-form"): impl Into<StringAttribute>,
873        ascent: impl Into<StringAttribute>,
874        attributeName("attributeName"): impl Into<StringAttribute>,
875        attributeType("attributeType"): impl Into<StringAttribute>,
876        azimuth: impl Into<StringAttribute>,
877        baseFrequency("baseFrequency"): impl Into<StringAttribute>,
878        baselineShift("baseline-shift"): impl Into<StringAttribute>,
879        baseProfile("baseProfile"): impl Into<StringAttribute>,
880        bbox: impl Into<StringAttribute>,
881        begin: impl Into<StringAttribute>,
882        bias: impl Into<StringAttribute>,
883        by: impl Into<StringAttribute>,
884        calcMode("calcMode"): impl Into<StringAttribute>,
885        capHeight("cap-height"): impl Into<StringAttribute>,
886        class: impl Into<StringAttribute>,
887        clipPathUnits("clipPathUnits"): impl Into<StringAttribute>,
888        clipPath("clip-path"): impl Into<StringAttribute>,
889        clipRule("clip-rule"): impl Into<StringAttribute>,
890        color: impl Into<StringAttribute>,
891        colorInterpolation("color-interpolation"): impl Into<StringAttribute>,
892        colorInterpolationFilters("color-interpolation-filters"): impl Into<StringAttribute>,
893        colorProfile("color-profile"): impl Into<StringAttribute>,
894        colorRendering("color-rendering"): impl Into<StringAttribute>,
895        crossorigin: impl Into<StringAttribute>,
896        cursor: impl Into<StringAttribute>,
897        cx: impl Into<StringAttribute>,
898        cy: impl Into<StringAttribute>,
899        d: impl Into<StringAttribute>,
900        decelerate: impl Into<StringAttribute>,
901        descent: impl Into<StringAttribute>,
902        diffuseConstant("diffuseConstant"): impl Into<StringAttribute>,
903        direction: impl Into<StringAttribute>,
904        display: impl Into<StringAttribute>,
905        divisor: impl Into<StringAttribute>,
906        dominantBaseline("dominant-baseline"): impl Into<StringAttribute>,
907        dur: impl Into<StringAttribute>,
908        dx: impl Into<StringAttribute>,
909        dy: impl Into<StringAttribute>,
910        edgeMode("edgeMode"): impl Into<StringAttribute>,
911        elevation: impl Into<StringAttribute>,
912        enableBackground("enable-background"): impl Into<StringAttribute>,
913        end: impl Into<StringAttribute>,
914        exponent: impl Into<StringAttribute>,
915        fill: impl Into<StringAttribute>,
916        fillOpacity("fill-opacity"): impl Into<StringAttribute>,
917        fillRule("fill-rule"): impl Into<StringAttribute>,
918        filter: impl Into<StringAttribute>,
919        filterUnits("filterUnits"): impl Into<StringAttribute>,
920        floodColor("flood-color"): impl Into<StringAttribute>,
921        floodOpacity("flood-opacity"): impl Into<StringAttribute>,
922        fontFamily("font-family"): impl Into<StringAttribute>,
923        fontSize("font-size"): impl Into<StringAttribute>,
924        fontSizeAdjust("font-size-adjust"): impl Into<StringAttribute>,
925        fontStretch("font-stretch"): impl Into<StringAttribute>,
926        fontStyle("font-style"): impl Into<StringAttribute>,
927        fontVariant("font-variant"): impl Into<StringAttribute>,
928        fontWeight("font-weight"): impl Into<StringAttribute>,
929        format: impl Into<StringAttribute>,
930        from: impl Into<StringAttribute>,
931        fr: impl Into<StringAttribute>,
932        fx: impl Into<StringAttribute>,
933        fy: impl Into<StringAttribute>,
934        g1: impl Into<StringAttribute>,
935        g2: impl Into<StringAttribute>,
936        glyphName("glyph-name"): impl Into<StringAttribute>,
937        glyphOrientationHorizontal("glyph-orientation-horizontal"): impl Into<StringAttribute>,
938        glyphOrientationVertical("glyph-orientation-vertical"): impl Into<StringAttribute>,
939        glyphRef: impl Into<StringAttribute>,
940        gradientTransform("gradientTransform"): impl Into<StringAttribute>,
941        gradientUnits("gradientUnits"): impl Into<StringAttribute>,
942        hanging: impl Into<StringAttribute>,
943        height: impl Into<StringAttribute>,
944        href: impl Into<StringAttribute>,
945        hreflang: impl Into<StringAttribute>,
946        horizAdvX("horiz-adv-x"): impl Into<StringAttribute>,
947        horizOriginX("horiz-origin-x"): impl Into<StringAttribute>,
948        id: impl Into<StringAttribute>,
949        ideographic: impl Into<StringAttribute>,
950        imageRendering("image-rendering"): impl Into<StringAttribute>,
951        in_: impl Into<StringAttribute>,
952        in2: impl Into<StringAttribute>,
953        intercept: impl Into<StringAttribute>,
954        k: impl Into<StringAttribute>,
955        k1: impl Into<StringAttribute>,
956        k2: impl Into<StringAttribute>,
957        k3: impl Into<StringAttribute>,
958        k4: impl Into<StringAttribute>,
959        kernelMatrix("kernelMatrix"): impl Into<StringAttribute>,
960        kernelUnitLength("kernelUnitLength"): impl Into<StringAttribute>,
961        kerning: impl Into<StringAttribute>,
962        keyPoints("keyPoints"): impl Into<StringAttribute>,
963        keySplines("keySplines"): impl Into<StringAttribute>,
964        keyTimes("keyTimes"): impl Into<StringAttribute>,
965        lang: impl Into<StringAttribute>,
966        lengthAdjust("lengthAdjust"): impl Into<StringAttribute>,
967        letterSpacing("letter-spacing"): impl Into<StringAttribute>,
968        lightingColor("lighting-color"): impl Into<StringAttribute>,
969        limitingConeAngle("limitingConeAngle"): impl Into<StringAttribute>,
970        local: impl Into<StringAttribute>,
971        markerEnd("marker-end"): impl Into<StringAttribute>,
972        markerMid("marker-mid"): impl Into<StringAttribute>,
973        markerStart("marker-start"): impl Into<StringAttribute>,
974        markerHeight("markerHeight"): impl Into<StringAttribute>,
975        markerUnits("markerUnits"): impl Into<StringAttribute>,
976        markerWidth("markerWidth"): impl Into<StringAttribute>,
977        mask: impl Into<StringAttribute>,
978        maskContentUnits("maskContentUnits"): impl Into<StringAttribute>,
979        maskUnits("maskUnits"): impl Into<StringAttribute>,
980        mathematical: impl Into<StringAttribute>,
981        max: impl Into<StringAttribute>,
982        media: impl Into<StringAttribute>,
983        method: impl Into<StringAttribute>,
984        min: impl Into<StringAttribute>,
985        mode: impl Into<StringAttribute>,
986        name: impl Into<StringAttribute>,
987        numOctaves("numOctaves"): impl Into<StringAttribute>,
988        offset: impl Into<StringAttribute>,
989        opacity: impl Into<StringAttribute>,
990        operator: impl Into<StringAttribute>,
991        order: impl Into<StringAttribute>,
992        orient: impl Into<StringAttribute>,
993        orientation: impl Into<StringAttribute>,
994        origin: impl Into<StringAttribute>,
995        overflow: impl Into<StringAttribute>,
996        overlinePosition("overline-position"): impl Into<StringAttribute>,
997        overlineThickness("overline-thickness"): impl Into<StringAttribute>,
998        panose1("panose-1"): impl Into<StringAttribute>,
999        paintOrder("paint-order"): impl Into<StringAttribute>,
1000        path: impl Into<StringAttribute>,
1001        pathLength("pathLength"): impl Into<StringAttribute>,
1002        patternContentUnits("patternContentUnits"): impl Into<StringAttribute>,
1003        patternTransform("patternTransform"): impl Into<StringAttribute>,
1004        patternUnits("patternUnits"): impl Into<StringAttribute>,
1005        ping: impl Into<StringAttribute>,
1006        pointerEvents("pointer-events"): impl Into<StringAttribute>,
1007        points: impl Into<StringAttribute>,
1008        pointsAtX("pointsAtX"): impl Into<StringAttribute>,
1009        pointsAtY("pointsAtY"): impl Into<StringAttribute>,
1010        pointsAtZ("pointsAtZ"): impl Into<StringAttribute>,
1011        preserveAlpha("preserveAlpha"): impl Into<StringAttribute>,
1012        preserveAspectRatio("preserveAspectRatio"): impl Into<StringAttribute>,
1013        primitiveUnits("primitiveUnits"): impl Into<StringAttribute>,
1014        r: impl Into<StringAttribute>,
1015        radius: impl Into<StringAttribute>,
1016        referrerPolicy("referrerPolicy"): impl Into<StringAttribute>,
1017        refX("refX"): impl Into<StringAttribute>,
1018        refY("refY"): impl Into<StringAttribute>,
1019        rel: impl Into<StringAttribute>,
1020        renderingIntent("rendering-intent"): impl Into<StringAttribute>,
1021        repeatCount("repeatCount"): impl Into<StringAttribute>,
1022        repeatDur("repeatDur"): impl Into<StringAttribute>,
1023        requiredExtensions("requiredExtensions"): impl Into<StringAttribute>,
1024        requiredFeatures("requiredFeatures"): impl Into<StringAttribute>,
1025        restart: impl Into<StringAttribute>,
1026        result: impl Into<StringAttribute>,
1027        rotate: impl Into<StringAttribute>,
1028        rx: impl Into<StringAttribute>,
1029        ry: impl Into<StringAttribute>,
1030        scale: impl Into<StringAttribute>,
1031        seed: impl Into<StringAttribute>,
1032        shapeRendering("shape-rendering"): impl Into<StringAttribute>,
1033        slope: impl Into<StringAttribute>,
1034        spacing: impl Into<StringAttribute>,
1035        specularConstant("specularConstant"): impl Into<StringAttribute>,
1036        specularExponent("specularExponent"): impl Into<StringAttribute>,
1037        speed: impl Into<StringAttribute>,
1038        spreadMethod("spreadMethod"): impl Into<StringAttribute>,
1039        startOffset("startOffset"): impl Into<StringAttribute>,
1040        stdDeviation("stdDeviation"): impl Into<StringAttribute>,
1041        stemh: impl Into<StringAttribute>,
1042        stemv: impl Into<StringAttribute>,
1043        stitchTiles("stitchTiles"): impl Into<StringAttribute>,
1044        stopColor("stop-color"): impl Into<StringAttribute>,
1045        stopOpacity("stop-opacity"): impl Into<StringAttribute>,
1046        strikethroughPosition("strikethrough-position"): impl Into<StringAttribute>,
1047        strikethroughThickness("strikethrough-thickness"): impl Into<StringAttribute>,
1048        string: impl Into<StringAttribute>,
1049        stroke: impl Into<StringAttribute>,
1050        strokeDasharray("stroke-dasharray"): impl Into<StringAttribute>,
1051        strokeDashoffset("stroke-dashoffset"): impl Into<StringAttribute>,
1052        strokeLinecap("stroke-linecap"): impl Into<StringAttribute>,
1053        strokeLinejoin("stroke-linejoin"): impl Into<StringAttribute>,
1054        strokeMiterlimit("stroke-miterlimit"): impl Into<StringAttribute>,
1055        strokeOpacity("stroke-opacity"): impl Into<StringAttribute>,
1056        strokeWidth("stroke-width"): impl Into<StringAttribute>,
1057        style: impl Into<StringAttribute>,
1058        surfaceScale("surfaceScale"): impl Into<StringAttribute>,
1059        systemLanguage("systemLanguage"): impl Into<StringAttribute>,
1060        tabindex: impl Into<StringAttribute>,
1061        tableValues("tableValues"): impl Into<StringAttribute>,
1062        target: impl Into<StringAttribute>,
1063        targetX("targetX"): impl Into<StringAttribute>,
1064        targetY("targetY"): impl Into<StringAttribute>,
1065        textAnchor("text-anchor"): impl Into<StringAttribute>,
1066        textDecoration("text-decoration"): impl Into<StringAttribute>,
1067        textRendering("text-rendering"): impl Into<StringAttribute>,
1068        textLength("textLength"): impl Into<StringAttribute>,
1069        to: impl Into<StringAttribute>,
1070        transform: impl Into<StringAttribute>,
1071        transformOrigin("transform-origin"): impl Into<StringAttribute>,
1072        type_: impl Into<StringAttribute>,
1073        u1: impl Into<StringAttribute>,
1074        u2: impl Into<StringAttribute>,
1075        underlinePosition("underline-position"): impl Into<StringAttribute>,
1076        underlineThickness("underline-thickness"): impl Into<StringAttribute>,
1077        unicode: impl Into<StringAttribute>,
1078        unicodeBidi("unicode-bidi"): impl Into<StringAttribute>,
1079        unicodeRange("unicode-range"): impl Into<StringAttribute>,
1080        unitsPerEm("units-per-em"): impl Into<StringAttribute>,
1081        vAlphabetic("v-alphabetic"): impl Into<StringAttribute>,
1082        vHanging("v-hanging"): impl Into<StringAttribute>,
1083        vIdeographic("v-ideographic"): impl Into<StringAttribute>,
1084        vMathematical("v-mathematical"): impl Into<StringAttribute>,
1085        values: impl Into<StringAttribute>,
1086        vectorEffect("vector-effect"): impl Into<StringAttribute>,
1087        version: impl Into<StringAttribute>,
1088        vertAdvY("vert-adv-y"): impl Into<StringAttribute>,
1089        vertOriginX("vert-origin-x"): impl Into<StringAttribute>,
1090        vertOriginY("vert-origin-y"): impl Into<StringAttribute>,
1091        viewBox: impl Into<StringAttribute>,
1092        visibility: impl Into<StringAttribute>,
1093        width: impl Into<StringAttribute>,
1094        widths: impl Into<StringAttribute>,
1095        wordSpacing("word-spacing"): impl Into<StringAttribute>,
1096        writingMode("writing-mode"): impl Into<StringAttribute>,
1097        x: impl Into<StringAttribute>,
1098        xHeight("x-height"): impl Into<StringAttribute>,
1099        x1: impl Into<StringAttribute>,
1100        x2: impl Into<StringAttribute>,
1101        xChannelSelector("xChannelSelector"): impl Into<StringAttribute>,
1102        xmlBase("xml:base"): impl Into<StringAttribute>,
1103        xmlLang("xml:lang"): impl Into<StringAttribute>,
1104        xmlSpace("xml:space"): impl Into<StringAttribute>,
1105        y: impl Into<StringAttribute>,
1106        y1: impl Into<StringAttribute>,
1107        y2: impl Into<StringAttribute>,
1108        yChannelSelector("yChannelSelector"): impl Into<StringAttribute>,
1109        zoomAndPan("zoomAndPan"): impl Into<StringAttribute>,
1110    }
1111}
1112
1113pub trait GlobalAttributes: SetAttribute + Sized {
1115    fn attr(mut self, name: &'static str, value: impl Into<StringAttribute>) -> Self {
1117        self.set_attribute(name, value.into());
1118        self
1119    }
1120
1121    fn bool_attr(mut self, name: &'static str, value: impl Into<MaybeDyn<bool>>) -> Self {
1123        self.set_attribute(name, value.into());
1124        self
1125    }
1126
1127    fn prop(mut self, name: &'static str, value: impl Into<MaybeDyn<JsValue>>) -> Self {
1129        self.set_attribute(name, value.into());
1130        self
1131    }
1132
1133    fn on<E: events::EventDescriptor, R>(
1135        mut self,
1136        _: E,
1137        mut handler: impl EventHandler<E, R>,
1138    ) -> Self {
1139        let scope = use_current_scope(); let handler = move |ev: web_sys::Event| scope.run_in(|| handler.call(ev.unchecked_into()));
1141        self.set_event_handler(E::NAME, handler);
1142        self
1143    }
1144
1145    fn bind<E: bind::BindDescriptor>(mut self, _: E, signal: Signal<E::ValueTy>) -> Self {
1147        let scope = use_current_scope(); let handler = move |ev: web_sys::Event| {
1149            scope.run_in(|| {
1150                let value =
1151                    js_sys::Reflect::get(&ev.current_target().unwrap(), &E::TARGET_PROPERTY.into())
1152                        .unwrap();
1153                signal.set(E::CONVERT_FROM_JS(&value).expect("failed to convert value from js"));
1154            })
1155        };
1156        self.set_event_handler(<E::Event as events::EventDescriptor>::NAME, handler);
1157
1158        self.prop(E::TARGET_PROPERTY, move || signal.get_clone().into())
1159    }
1160}
1161
1162impl<T: GlobalProps> GlobalAttributes for T {}
1163
1164pub trait GlobalProps: GlobalAttributes + AsHtmlNode + Sized {
1166    fn dangerously_set_inner_html(mut self, inner_html: impl Into<Cow<'static, str>>) -> Self {
1168        self.as_html_node().set_inner_html(inner_html.into());
1169        self
1170    }
1171
1172    fn children(mut self, children: impl Into<View>) -> Self {
1174        self.as_html_node().append_view(children.into());
1175        self
1176    }
1177
1178    fn r#ref(mut self, noderef: NodeRef) -> Self {
1180        if is_not_ssr!() {
1181            noderef.set(Some(self.as_html_node().as_web_sys().clone()));
1182        }
1183        self
1184    }
1185
1186    fn spread(mut self, attributes: Attributes) -> Self {
1187        attributes.apply_self(self.as_html_node());
1188        self
1189    }
1190}