Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSerialize the children of void html elements as empty strings #22542
Conversation
highfive
commented
Dec 23, 2018
|
Heads up! This PR modifies the following files:
|
|
I found the servo/components/script/dom/element.rs Lines 1099 to 1101 in 29eb8bd Ref: |
| @@ -1108,6 +1108,15 @@ impl Element { | |||
| } | |||
|
|
|||
| pub fn serialize(&self, traversal_scope: TraversalScope) -> Fallible<DOMString> { | |||
| match traversal_scope { | |||
| TraversalScope::ChildrenOnly(_) => { | |||
This comment has been minimized.
This comment has been minimized.
CYBAI
Dec 23, 2018
Collaborator
Maybe we can use if let here?
if let TraversalScope::ChildrenOnly(_) = traversal_scope {
if self.is_void() {
return Ok(DOMString::from(""));
}
}|
@bors-servo r+ |
|
|
…y_strings, r=paulrouget Serialize the children of void html elements as empty strings <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #22502 (GitHub issue number if applicable) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22542) <!-- Reviewable:end -->
|
|
|
It's not totally clear to me whether this code belongs in html5ever or Servo. I would like to review it further. |
|
I have reviewed the specification and this code change looks too specific to me. I'll add some more information to the github issue, since the code change likely belongs in the html5ever repository. |
|
I've changed my mind - I think this change is necessary, but I think it belongs in components/script/dom/servoparser/html.rs in Node::serialize instead. |
| @@ -210,6 +210,12 @@ impl<'a> Serialize for &'a Node { | |||
| ) -> io::Result<()> { | |||
| let node = *self; | |||
|
|
|||
| if let TraversalScope::ChildrenOnly(_) = traversal_scope { | |||
| if node.downcast::<Element>().unwrap().is_void() { | |||
This comment has been minimized.
This comment has been minimized.
jdm
Jan 2, 2019
Member
We should use if node.downcast::<Element>().map_or(false, |e| e.is_void()) { instead, so we do not panic when serializing non-element nodes.
|
@bors-servo r+ |
|
|
…y_strings, r=jdm Serialize the children of void html elements as empty strings <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #22502 (GitHub issue number if applicable) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22542) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
…y_strings, r=jdm Serialize the children of void html elements as empty strings <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #22502 (GitHub issue number if applicable) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22542) <!-- Reviewable:end -->
|
|
georgeroman commentedDec 23, 2018
•
edited by SimonSapin
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is