question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Newlines in html template in minified js?

See original GitHub issue

Downloading 3.1.2 from NPM (and other versions as far as I can tell) seems to contain newlines in the html template used for displaying the cursor flag. These newlines render and make it appear as though there is a lot of padding around the name.

I narrowed it down to this minified code: o='\n <span class="'.concat(i.default.SELECTION_CLASS,'"></span>\n <span class="').concat(i.default.CARET_CONTAINER_CLASS,'">\n <span class="').concat(i.default.CARET_CLASS,'"></span>\n </span>\n <div class="').concat(i.default.FLAG_CLASS,'">\n <small class="').concat(i.default.NAME_CLASS,'"></small>\n </div>\n');

When I remove the newlines from that minified code, everything renders quite well. Seems like this is unintentional.

Attached image of how it looks (with text selected highlighting the newline). Let me know if I’m just missing something! image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanVolonscommented, Jul 21, 2022

Omg @alecgibson you nailed it! The container I had this in had white-space: pre-wrap; and when I removed that, the cursor was displaying as desired. Thanks for pointing this out; I hadn’t realized the implications of that css property (and I think I accidentally left it there after some experimentation on an unrelated issue). I think we can close this issue - thank you!!

0reactions
alecgibsoncommented, Jul 19, 2022

@IvanVolons I’m not sure I understand the issue. Whitespace should be collapsed by the browser, so newlines in the source code shouldn’t matter, unless you’ve set something like white-space: pre;?

Can you please check the white-space value of that DOM node, and report back? It should be set (by this library) to nowrap. If that looks normal, let us know which browser you’re using, and please provide an MWE.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rendering new line or line breaks in a template literal?
CSV into formatted html code for production purposes. I have built the functionality of converting the file into a template literal using .map() ......
Read more >
Strange Line Breaks · Issue #3 · nystudio107/minify - GitHub
I am wrapping the entire contents of a layout template in minify tags – but the output is still over 500 lines long....
Read more >
How to Preserve Newlines, Line Breaks, and Whitespace in ...
Preserve Newlines, Line Breaks, and Whitespace in HTML. Use the white-space: pre; setting to display long-form content containing whitespace and ...
Read more >
Add New Line in JavaScript - HereWeCode
The last way to add a newline in JavaScript is to use the <br> HTML tag. You can use it in an HTML...
Read more >
<br>: The Line Break element - HTML - MDN Web Docs - Mozilla
The HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found