mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Return error when setting invalid <table> caption (#30020)
* Return error when setting invalid <table> caption Signed-off-by: thesecretmaster <thesecretmaster@developingtechnician.com> * Forgot to commit style changes Signed-off-by: thesecretmaster <thesecretmaster@developingtechnician.com> --------- Signed-off-by: thesecretmaster <thesecretmaster@developingtechnician.com>
This commit is contained in:
parent
bce7622cde
commit
c28404e9fa
2 changed files with 7 additions and 5 deletions
|
@ -188,16 +188,17 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-table-caption
|
// https://html.spec.whatwg.org/multipage/#dom-table-caption
|
||||||
fn SetCaption(&self, new_caption: Option<&HTMLTableCaptionElement>) {
|
fn SetCaption(&self, new_caption: Option<&HTMLTableCaptionElement>) -> Fallible<()> {
|
||||||
if let Some(ref caption) = self.GetCaption() {
|
if let Some(ref caption) = self.GetCaption() {
|
||||||
caption.upcast::<Node>().remove_self();
|
caption.upcast::<Node>().remove_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(caption) = new_caption {
|
if let Some(caption) = new_caption {
|
||||||
let node = self.upcast::<Node>();
|
let node = self.upcast::<Node>();
|
||||||
node.InsertBefore(caption.upcast(), node.GetFirstChild().as_deref())
|
node.InsertBefore(caption.upcast(), node.GetFirstChild().as_deref())?;
|
||||||
.expect("Insertion failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-table-createcaption
|
// https://html.spec.whatwg.org/multipage/#dom-table-createcaption
|
||||||
|
@ -211,7 +212,8 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
||||||
&document_from_node(self),
|
&document_from_node(self),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
self.SetCaption(Some(&caption));
|
self.SetCaption(Some(&caption))
|
||||||
|
.expect("Generated caption is invalid");
|
||||||
caption
|
caption
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
interface HTMLTableElement : HTMLElement {
|
interface HTMLTableElement : HTMLElement {
|
||||||
[HTMLConstructor] constructor();
|
[HTMLConstructor] constructor();
|
||||||
|
|
||||||
[CEReactions]
|
[CEReactions, SetterThrows]
|
||||||
attribute HTMLTableCaptionElement? caption;
|
attribute HTMLTableCaptionElement? caption;
|
||||||
HTMLTableCaptionElement createCaption();
|
HTMLTableCaptionElement createCaption();
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue