mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add script::dom::utils::validate_qualified_name()
This commit is contained in:
parent
7e07dcc7ee
commit
abc01d598a
4 changed files with 29 additions and 39 deletions
|
@ -7,7 +7,7 @@
|
|||
use dom::bindings::codegen::PrototypeList;
|
||||
use dom::bindings::codegen::PrototypeList::MAX_PROTO_CHAIN_LENGTH;
|
||||
use dom::bindings::conversions::{native_from_reflector_jsmanaged, is_dom_class};
|
||||
use dom::bindings::error::throw_type_error;
|
||||
use dom::bindings::error::{Error, ErrorResult, throw_type_error};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{Temporary, Root};
|
||||
use dom::browsercontext;
|
||||
|
@ -604,6 +604,21 @@ pub unsafe fn delete_property_by_id(cx: *mut JSContext, object: *mut JSObject,
|
|||
return true;
|
||||
}
|
||||
|
||||
/// Validate a qualified name. See https://dom.spec.whatwg.org/#validate for details.
|
||||
pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult {
|
||||
match xml_name_type(qualified_name) {
|
||||
XMLName::InvalidXMLName => {
|
||||
// Step 1.
|
||||
return Err(Error::InvalidCharacter);
|
||||
},
|
||||
XMLName::Name => {
|
||||
// Step 2.
|
||||
return Err(Error::Namespace);
|
||||
},
|
||||
XMLName::QName => Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Results of `xml_name_type`.
|
||||
#[derive(PartialEq)]
|
||||
#[allow(missing_docs)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue