Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #14341 - stshine:where-is-the-top, r=mrobinson,emilio
script: Fix the scroll to top behavior <!-- Please describe your changes on the following line: --> When finding the indicated fragment, do not use the document element to indicate the top of the Document, and when scrolling to the frament and we do not find a element, scrolling the top if the fragment is empty or equal to "top". --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because _____ <!-- 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/14341) <!-- Reviewable:end -->
- Loading branch information
Showing
3 changed files
with
54 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/wpt/mozilla/tests/mozilla/scroll_top_null_target.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title></title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<a id="test"></a> | ||
</body> | ||
<script> | ||
test(function() { | ||
location.hash = "test"; | ||
assert_equals(document.querySelector(":target"), document.getElementById("test"), | ||
"Target shoud be the same with the test anchor!"); | ||
location.hash = ""; | ||
assert_equals(document.querySelector(":target"), null, "Target should be null!"); | ||
}); | ||
</script> | ||
</html> |