script/dom/execcommand/contenteditable/
document.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 js::context::JSContext;
6
7use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
8    DocumentMethods, ElementCreationOptions,
9};
10use crate::dom::bindings::codegen::UnionTypes::StringOrElementCreationOptions;
11use crate::dom::bindings::root::DomRoot;
12use crate::dom::document::Document;
13use crate::dom::element::Element;
14
15impl Document {
16    pub(crate) fn create_element(&self, cx: &mut JSContext, name: &str) -> DomRoot<Element> {
17        let element_options =
18            StringOrElementCreationOptions::ElementCreationOptions(ElementCreationOptions {
19                is: None,
20            });
21        self.CreateElement(cx, name.into(), element_options)
22            .expect("Must always be able to create element")
23    }
24}