Fix locationOf for empty hash targets in Webkit#1300
Open
elliotdickison wants to merge 2 commits intofuturepress:masterfrom
Open
Fix locationOf for empty hash targets in Webkit#1300elliotdickison wants to merge 2 commits intofuturepress:masterfrom
elliotdickison wants to merge 2 commits intofuturepress:masterfrom
Conversation
Internal hash links were broken in Webkit if they pointed to empty elements. This change fixes that by temporarily inserting a zero-width space into elements before measuring them.
Contributor
|
The function seems to contradict itself. In WebKit, in the case of a collapsed range, it tries to use an element instead of the range, but then in the case of an element, it does the exact opposite, creating a range from the element, which in the case of an empty element would result in a collapsed range. Testing it a bit, with the latest WebKitGTK, I believe the problem is actually that a collapsed range doesn't return the correct rect. For elements, it reports the correct rect, whether the element is empty or in columns or not. So I think this can be fixed by simply removing the check all together: diff --git a/src/contents.js b/src/contents.js
index 3effe72..63d0482 100644
--- a/src/contents.js
+++ b/src/contents.js
@@ -666,14 +666,7 @@ class Contents {
let id = target.substring(target.indexOf("#")+1);
let el = this.document.getElementById(id);
if(el) {
- if (isWebkit) {
- // Webkit reports incorrect bounding rects in Columns
- let newRange = new Range();
- newRange.selectNode(el);
- position = newRange.getBoundingClientRect();
- } else {
- position = el.getBoundingClientRect();
- }
+ position = el.getBoundingClientRect();
}
} |
Author
|
Ha good catch, works for me! |
Author
|
@fchasen Any chance you could merge this? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Internal hash links were broken in Webkit if they pointed to empty elements. This change fixes that by temporarily inserting a zero-width space into elements before measuring them.