aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltableelement.rs
diff options
context:
space:
mode:
authorDavid Zbarsky <dzbarsky@gmail.com>2015-08-07 04:07:15 -0400
committerDavid Zbarsky <dzbarsky@gmail.com>2015-08-08 15:24:05 -0400
commite24a867ab69a898915fa0ee80f4cfc56eb5e622c (patch)
tree4b474bb6e410c0e611881666a78ec3dc4d2a7ed9 /components/script/dom/htmltableelement.rs
parent78792cced2c4f1702a0bc2039bdebf07f8bcd901 (diff)
downloadservo-e24a867ab69a898915fa0ee80f4cfc56eb5e622c.tar.gz
servo-e24a867ab69a898915fa0ee80f4cfc56eb5e622c.zip
Implement createCaption and deleteCaption on HTMLTableElement
Update web-platform-tests expected data
Diffstat (limited to 'components/script/dom/htmltableelement.rs')
-rw-r--r--components/script/dom/htmltableelement.rs29
1 files changed, 26 insertions, 3 deletions
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs
index 41f0af855e7..a8a1cdf1b7b 100644
--- a/components/script/dom/htmltableelement.rs
+++ b/components/script/dom/htmltableelement.rs
@@ -14,7 +14,7 @@ use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::element::ElementTypeId;
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
-use dom::node::{Node, NodeHelpers, NodeTypeId};
+use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node};
use dom::virtualmethods::VirtualMethods;
use util::str::{self, DOMString, LengthOrPercentageOrAuto};
@@ -80,11 +80,34 @@ impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
let node = NodeCast::from_ref(self);
if let Some(ref caption) = self.GetCaption() {
- assert!(node.RemoveChild(NodeCast::from_ref(caption.r())).is_ok());
+ NodeCast::from_ref(caption.r()).remove_self();
}
if let Some(caption) = new_caption {
- assert!(node.AppendChild(NodeCast::from_ref(caption)).is_ok());
+ assert!(node.InsertBefore(NodeCast::from_ref(caption),
+ node.GetFirstChild().as_ref().map(|n| n.r())).is_ok());
+ }
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-table-createcaption
+ fn CreateCaption(self) -> Root<HTMLElement> {
+ let caption = match self.GetCaption() {
+ Some(caption) => caption,
+ None => {
+ let caption = HTMLTableCaptionElement::new("caption".to_owned(),
+ None,
+ document_from_node(self).r());
+ self.SetCaption(Some(caption.r()));
+ caption
+ }
+ };
+ HTMLElementCast::from_root(caption)
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-table-deletecaption
+ fn DeleteCaption(self) {
+ if let Some(caption) = self.GetCaption() {
+ NodeCast::from_ref(caption.r()).remove_self();
}
}
}