Issue #989Opened March 29, 2018by tommedema1 reactions

[BUG] Consecutive spans render whitespace differently in grapes' editor than in ordinary window

Question

I've spent the greater part of an afternoon trying to debug this. While I have reduced this to a small and easy to reproduce test case, I didn't find the root cause of this issue yet. Hopefully someone can help.

Note the following HTML template:

<!DOCTYPE html>
<html>
<head>

<style>
body {
  margin: 0;
}

.navbar-main .main-navigation__list {
  margin: 0;
  padding: 0; 
}

.navbar-main .main-navigation__list .main-navigation__list-item {
  display: inline-block;
}
</style>
</head>

<body>
  <nav class="navbar-main">
    <div>
      <ol class="main-navigation__list">
        <li class="main-navigation__list-item">
          <span>Our solution</span>
        </li>
        <li class="main-navigation__list-item">
          <span>About</span>
        </li>
      </ol>
    </div>
  </nav>
</body>
</html>

If you render this in a browser, it renders as:

<img width="133" alt="screen shot 2018-03-29 at 1 36 34 pm" src="https://user-images.githubusercontent.com/331833/38112278-47c661fe-3356-11e8-8186-d48791b01af7.png">

Notice the whitespace between "Our solution" and "About".

If you then use the exact HTML and style as Grapes's template, it will render as:

<img width="173" alt="screen shot 2018-03-29 at 1 36 44 pm" src="https://user-images.githubusercontent.com/331833/38112304-5c2592dc-3356-11e8-83b6-946b68cc2c59.png">

Notice that the whitespace is now not visible. The expected behavior is for grapes to render the template in the same manner as a browser does without grapes.

JSFiddle to reproduce:

https://jsfiddle.net/szLp8h4n/89/

Change autorender: 0 to autorender: 1 to trigger the bug.

Could this be because Grapes has a manual HTML and CSS parser, meaning that the DOM or CSS rules are replicated invalidly in this particular case? Can you figure out where it goes wrong?

Answers (3)

artfApril 5, 20181 reactions

Yeah Tom thanks, I think a configurable option (eg. keepWhitespace?!?) might be a good solution

tommedemaApril 2, 20180 reactions

Thanks @artf, I see. I would suggest removing this or at least making this configurable (defaulting to true then to prevent breaking changes). Would you accept a PR for this?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.