diff options
author | Simon Wülker <simon.wuelker@arcor.de> | 2025-02-19 05:34:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-19 04:34:42 +0000 |
commit | 29e0fad21ec561b1778e8d973c4e800702f1b38b (patch) | |
tree | e7b44428d785374bc91388449080bc2b8b5c5efa /components/script/dom/domimplementation.rs | |
parent | b57eba29196f16f5fb4460532b64471790d249e8 (diff) | |
download | servo-29e0fad21ec561b1778e8d973c4e800702f1b38b.tar.gz servo-29e0fad21ec561b1778e8d973c4e800702f1b38b.zip |
Ensure that qualified-name segments start with a valid start character (#35530)
* Add spec comments to various methods
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Ensure that qualified-name segments start with a valid start character
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Update WPT expectations
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Diffstat (limited to 'components/script/dom/domimplementation.rs')
-rw-r--r-- | components/script/dom/domimplementation.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index c263ba940af..af68edfc825 100644 --- a/components/script/dom/domimplementation.rs +++ b/components/script/dom/domimplementation.rs @@ -18,7 +18,9 @@ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; -use crate::dom::bindings::xmlname::{namespace_from_domstring, validate_qualified_name}; +use crate::dom::bindings::xmlname::{ + namespace_from_domstring, validate_and_extract_qualified_name, +}; use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument}; use crate::dom::documenttype::DocumentType; use crate::dom::htmlbodyelement::HTMLBodyElement; @@ -57,7 +59,7 @@ impl DOMImplementation { // https://dom.spec.whatwg.org/#domimplementation impl DOMImplementationMethods<crate::DomTypeHolder> for DOMImplementation { - // https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype + /// <https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype> fn CreateDocumentType( &self, qualified_name: DOMString, @@ -65,7 +67,9 @@ impl DOMImplementationMethods<crate::DomTypeHolder> for DOMImplementation { sysid: DOMString, can_gc: CanGc, ) -> Fallible<DomRoot<DocumentType>> { - validate_qualified_name(&qualified_name)?; + // Step 1. Validate qualifiedName. + validate_and_extract_qualified_name(&qualified_name)?; + Ok(DocumentType::new( qualified_name, Some(pubid), @@ -75,7 +79,7 @@ impl DOMImplementationMethods<crate::DomTypeHolder> for DOMImplementation { )) } - // https://dom.spec.whatwg.org/#dom-domimplementation-createdocument + /// <https://dom.spec.whatwg.org/#dom-domimplementation-createdocument> fn CreateDocument( &self, maybe_namespace: Option<DOMString>, @@ -107,7 +111,10 @@ impl DOMImplementationMethods<crate::DomTypeHolder> for DOMImplementation { loader, Some(self.document.insecure_requests_policy()), ); - // Step 2-3. + + // Step 2. Let element be null. + // Step 3. If qualifiedName is not the empty string, then set element to the result of running + // the internal createElementNS steps, given document, namespace, qualifiedName, and an empty dictionary. let maybe_elem = if qname.is_empty() { None } else { |