-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(line-numbers): line height will be zero when <pre> is hidden #2352
Conversation
@@ -44,8 +44,8 @@ | |||
|
|||
codeLines.forEach(function (line, lineNumber) { | |||
lineNumberSizer.textContent = line || '\n'; | |||
var lineSize = lineNumberSizer.getBoundingClientRect().height; | |||
lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px'; | |||
var lineSize = getComputedStyle(lineNumberSizer).lineHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assume that getComputedStyle(lineNumberSizer).lineHeight
is equivalent to lineNumberSizer.getBoundingClientRect().height + 'px'
? Especially cross browser?
(Line Numbers is one of our most-used plugins, so I don't want to break websites just because this change seems sound.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we set lineSize to be lineNumberSizer.getBoundingClientRect().height + 'px'
by default?Only when lineNumberSizer.getBoundingClientRect().height
equals 0 will we set it to getComputedStyle(lineNumberSizer).lineHeight
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RunDevelopment Request for your comments. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't think we should fix this internally. If the @RunDevelopment I'd be ok with closing (we still appreciate the contribution!), but I'd like to hear your opinion given you've played with this. |
@mAAdhaTTah I agree. Rehighlighting will trivially solve this issue (though it's a bit of a waste performance-wise). I think we should rather focus on #2413. After this PR, we can let the browser do the positioning of line numbers (and line highlights), so we don't have to worry about this (and a few other issues) at all. |
When the
<pre>
element is hidden by default,lineNumberSizer.getBoundingClientRect().height
will be 0.When the user sets hidden to false,line numbers will be displayed as follows.This is not the expected display.