script/dom/html/
htmldataelement.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use dom_struct::dom_struct;
6use html5ever::{LocalName, Prefix};
7use js::rust::HandleObject;
8
9use crate::dom::bindings::codegen::Bindings::HTMLDataElementBinding::HTMLDataElementMethods;
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::bindings::str::DOMString;
12use crate::dom::document::Document;
13use crate::dom::html::htmlelement::HTMLElement;
14use crate::dom::node::Node;
15use crate::script_runtime::CanGc;
16
17#[dom_struct]
18pub(crate) struct HTMLDataElement {
19    htmlelement: HTMLElement,
20}
21
22impl HTMLDataElement {
23    fn new_inherited(
24        local_name: LocalName,
25        prefix: Option<Prefix>,
26        document: &Document,
27    ) -> HTMLDataElement {
28        HTMLDataElement {
29            htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
30        }
31    }
32
33    pub(crate) fn new(
34        local_name: LocalName,
35        prefix: Option<Prefix>,
36        document: &Document,
37        proto: Option<HandleObject>,
38        can_gc: CanGc,
39    ) -> DomRoot<HTMLDataElement> {
40        Node::reflect_node_with_proto(
41            Box::new(HTMLDataElement::new_inherited(local_name, prefix, document)),
42            document,
43            proto,
44            can_gc,
45        )
46    }
47}
48
49impl HTMLDataElementMethods<crate::DomTypeHolder> for HTMLDataElement {
50    // https://html.spec.whatwg.org/multipage/#dom-data-value
51    make_getter!(Value, "value");
52
53    // https://html.spec.whatwg.org/multipage/#dom-data-value
54    make_setter!(SetValue, "value");
55}