diff options
author | thesecretmaster <15304293+thesecretmaster@users.noreply.github.com> | 2023-08-08 11:30:55 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 16:30:55 +0000 |
commit | c28404e9fa57c134210b92a7736833f3ac04dd28 (patch) | |
tree | 359cb1e68e4a99d21041458bbc57dbffabf4f1c3 /components/script/dom/htmltableelement.rs | |
parent | bce7622cde4cd10f6b3edf852d97ae9a540a0076 (diff) | |
download | servo-c28404e9fa57c134210b92a7736833f3ac04dd28.tar.gz servo-c28404e9fa57c134210b92a7736833f3ac04dd28.zip |
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>
Diffstat (limited to 'components/script/dom/htmltableelement.rs')
-rw-r--r-- | components/script/dom/htmltableelement.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 50a1152fb7c..6ce8c0569e1 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -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 }, } |