aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorGeorge Roman <george.roman.99@gmail.com>2019-02-13 22:21:52 +0200
committerGeorge Roman <george.roman.99@gmail.com>2019-03-14 21:41:02 +0200
commit4b8282b3b164771e3351c2a85890167ab6d0ab7f (patch)
tree8a8d7ef29732300b5a24919524aa3e56f7e45e84 /components/script/dom/document.rs
parent431423388ee97fcbf23b5f7bbb6e8cf2c86740a5 (diff)
downloadservo-4b8282b3b164771e3351c2a85890167ab6d0ab7f.tar.gz
servo-4b8282b3b164771e3351c2a85890167ab6d0ab7f.zip
Implement CDATASection interface and createCDATASection method
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs17
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)