mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Auto merge of #25373 - pshaughn:ce_options_string, r=jdm
let document.createElement[NS] accept a string for options The string actually does nothing, but spec and WPT don't want it to do anything. https://dom.spec.whatwg.org/#dom-document-createelement only cares about the options value when it's a dictionary, and the WPT test on the string case is just that it isn't throwing an exception. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25008 <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
dadbc36f8c
5 changed files with 24 additions and 18 deletions
|
@ -11,7 +11,6 @@ use crate::dom::bindings::callback::ExceptionHandling;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
|
use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding;
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::ElementCreationOptions;
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
||||||
DocumentMethods, DocumentReadyState,
|
DocumentMethods, DocumentReadyState,
|
||||||
};
|
};
|
||||||
|
@ -25,7 +24,7 @@ use crate::dom::bindings::codegen::Bindings::TouchBinding::TouchMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::{
|
use crate::dom::bindings::codegen::Bindings::WindowBinding::{
|
||||||
FrameRequestCallback, ScrollBehavior, WindowMethods,
|
FrameRequestCallback, ScrollBehavior, WindowMethods,
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::codegen::UnionTypes::NodeOrString;
|
use crate::dom::bindings::codegen::UnionTypes::{NodeOrString, StringOrElementCreationOptions};
|
||||||
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||||
use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||||
use crate::dom::bindings::num::Finite;
|
use crate::dom::bindings::num::Finite;
|
||||||
|
@ -3622,7 +3621,7 @@ impl DocumentMethods for Document {
|
||||||
fn CreateElement(
|
fn CreateElement(
|
||||||
&self,
|
&self,
|
||||||
mut local_name: DOMString,
|
mut local_name: DOMString,
|
||||||
options: &ElementCreationOptions,
|
options: StringOrElementCreationOptions,
|
||||||
) -> Fallible<DomRoot<Element>> {
|
) -> Fallible<DomRoot<Element>> {
|
||||||
if xml_name_type(&local_name) == InvalidXMLName {
|
if xml_name_type(&local_name) == InvalidXMLName {
|
||||||
debug!("Not a valid element name");
|
debug!("Not a valid element name");
|
||||||
|
@ -3643,7 +3642,12 @@ impl DocumentMethods for Document {
|
||||||
};
|
};
|
||||||
|
|
||||||
let name = QualName::new(None, ns, LocalName::from(local_name));
|
let name = QualName::new(None, ns, LocalName::from(local_name));
|
||||||
let is = options.is.as_ref().map(|is| LocalName::from(&**is));
|
let is = match options {
|
||||||
|
StringOrElementCreationOptions::String(_) => None,
|
||||||
|
StringOrElementCreationOptions::ElementCreationOptions(options) => {
|
||||||
|
options.is.as_ref().map(|is| LocalName::from(&**is))
|
||||||
|
},
|
||||||
|
};
|
||||||
Ok(Element::create(
|
Ok(Element::create(
|
||||||
name,
|
name,
|
||||||
is,
|
is,
|
||||||
|
@ -3658,11 +3662,16 @@ impl DocumentMethods for Document {
|
||||||
&self,
|
&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
qualified_name: DOMString,
|
qualified_name: DOMString,
|
||||||
options: &ElementCreationOptions,
|
options: StringOrElementCreationOptions,
|
||||||
) -> Fallible<DomRoot<Element>> {
|
) -> Fallible<DomRoot<Element>> {
|
||||||
let (namespace, prefix, local_name) = validate_and_extract(namespace, &qualified_name)?;
|
let (namespace, prefix, local_name) = validate_and_extract(namespace, &qualified_name)?;
|
||||||
let name = QualName::new(prefix, namespace, local_name);
|
let name = QualName::new(prefix, namespace, local_name);
|
||||||
let is = options.is.as_ref().map(|is| LocalName::from(&**is));
|
let is = match options {
|
||||||
|
StringOrElementCreationOptions::String(_) => None,
|
||||||
|
StringOrElementCreationOptions::ElementCreationOptions(options) => {
|
||||||
|
options.is.as_ref().map(|is| LocalName::from(&**is))
|
||||||
|
},
|
||||||
|
};
|
||||||
Ok(Element::create(
|
Ok(Element::create(
|
||||||
name,
|
name,
|
||||||
is,
|
is,
|
||||||
|
|
|
@ -9,6 +9,7 @@ use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
||||||
DocumentMethods, ElementCreationOptions,
|
DocumentMethods, ElementCreationOptions,
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
|
use crate::dom::bindings::codegen::UnionTypes::StringOrElementCreationOptions;
|
||||||
use crate::dom::bindings::error::Fallible;
|
use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||||
|
@ -105,10 +106,13 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
let maybe_elem = if qname.is_empty() {
|
let maybe_elem = if qname.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let options = ElementCreationOptions { is: None };
|
let options =
|
||||||
|
StringOrElementCreationOptions::ElementCreationOptions(ElementCreationOptions {
|
||||||
|
is: None,
|
||||||
|
});
|
||||||
match doc
|
match doc
|
||||||
.upcast::<Document>()
|
.upcast::<Document>()
|
||||||
.CreateElementNS(maybe_namespace, qname, &options)
|
.CreateElementNS(maybe_namespace, qname, options)
|
||||||
{
|
{
|
||||||
Err(error) => return Err(error),
|
Err(error) => return Err(error),
|
||||||
Ok(elem) => Some(elem),
|
Ok(elem) => Some(elem),
|
||||||
|
|
|
@ -34,9 +34,10 @@ interface Document : Node {
|
||||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||||
|
|
||||||
[CEReactions, NewObject, Throws]
|
[CEReactions, NewObject, Throws]
|
||||||
Element createElement(DOMString localName, optional ElementCreationOptions options = {});
|
Element createElement(DOMString localName, optional (DOMString or ElementCreationOptions) options = {});
|
||||||
[CEReactions, NewObject, Throws]
|
[CEReactions, NewObject, Throws]
|
||||||
Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional ElementCreationOptions options = {});
|
Element createElementNS(DOMString? namespace, DOMString qualifiedName,
|
||||||
|
optional (DOMString or ElementCreationOptions) options = {});
|
||||||
[NewObject]
|
[NewObject]
|
||||||
DocumentFragment createDocumentFragment();
|
DocumentFragment createDocumentFragment();
|
||||||
[NewObject]
|
[NewObject]
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
[Document-createElement.html]
|
[Document-createElement.html]
|
||||||
[document.createElement must create an instance of autonomous custom elements when it has is attribute]
|
[document.createElement must create an instance of autonomous custom elements when it has is attribute]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[document.createElement()'s second argument is to be ignored when it's a string]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[Document-createElementNS.html]
|
|
||||||
[document.createElementNS()'s third argument is to be ignored when it's a string]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue