diff options
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 91ccc829719..b589d4e5b79 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -35,6 +35,7 @@ use crate::dom::bindings::xmlname::XMLName::InvalidXMLName; use crate::dom::bindings::xmlname::{ namespace_from_domstring, validate_and_extract, xml_name_type, }; +use crate::dom::cdatasection::CDATASection; use crate::dom::closeevent::CloseEvent; use crate::dom::comment::Comment; use crate::dom::compositionevent::CompositionEvent; @@ -3610,6 +3611,22 @@ impl DocumentMethods for Document { Text::new(data, self) } + // https://dom.spec.whatwg.org/#dom-document-createcdatasection + fn CreateCDATASection(&self, data: DOMString) -> Fallible<DomRoot<CDATASection>> { + // Step 1 + if self.is_html_document { + return Err(Error::NotSupported); + } + + // Step 2 + if data.contains("]]>") { + return Err(Error::InvalidCharacter); + } + + // Step 3 + Ok(CDATASection::new(data, self)) + } + // https://dom.spec.whatwg.org/#dom-document-createcomment fn CreateComment(&self, data: DOMString) -> DomRoot<Comment> { Comment::new(data, self) |