mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
||||
fn SetCaption(&self, new_caption: Option<&HTMLTableCaptionElement>) {
|
||||
fn SetCaption(&self, new_caption: Option<&HTMLTableCaptionElement>) -> Fallible<()> {
|
||||
if let Some(ref caption) = self.GetCaption() {
|
||||
caption.upcast::<Node>().remove_self();
|
||||
}
|
||||
|
||||
if let Some(caption) = new_caption {
|
||||
let node = self.upcast::<Node>();
|
||||
node.InsertBefore(caption.upcast(), node.GetFirstChild().as_deref())
|
||||
.expect("Insertion failed");
|
||||
node.InsertBefore(caption.upcast(), node.GetFirstChild().as_deref())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-table-createcaption
|
||||
|
@ -211,7 +212,8 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
&document_from_node(self),
|
||||
None,
|
||||
);
|
||||
self.SetCaption(Some(&caption));
|
||||
self.SetCaption(Some(&caption))
|
||||
.expect("Generated caption is invalid");
|
||||
caption
|
||||
},
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
interface HTMLTableElement : HTMLElement {
|
||||
[HTMLConstructor] constructor();
|
||||
|
||||
[CEReactions]
|
||||
[CEReactions, SetterThrows]
|
||||
attribute HTMLTableCaptionElement? caption;
|
||||
HTMLTableCaptionElement createCaption();
|
||||
[CEReactions]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue