Issue #1577Opened November 14, 2018by emilsedgh1 reactions

Inline CSS Comments break Code Manager

Question

Apparently this is valid piece of html and css:

<div style="color: red; /* height 200px; */; font-weight: bold;">

(Hence the commented out height property)

Grapesjs has trouble dealing with such attribute as the style attribute on the model is stored as this:

screenshot_20181113_165603

The big problem is that CssGenerator's buildFromObject considers /* as part of the rule name for /* height, and concatenates it the whole css string. So the css code is basically commented out when it reaches this model and is rendered unusable blob of commented out css.

Obviously the real fix is not on CodeManager. Whoever parses /* height to be a rule name is making a mistake.

Answers (3)

emilsedghAugust 24, 20191 reactions

Alright I finally managed to reproduce this again. Reopening with better fiddle.

The code inside gjs is

  <p style="/* color: #ffffff; */"></p>
  <span style="color: red;">Bar</span>

The CSS retrieved by editor.getCss() is:

* { box-sizing: border-box; } body {margin: 0;}.c620{/* color:#ffffff;}.c629{color:red;}

The bug is that the /* color:#ffffff; doesn't have the closing comment tag. Therefore, it'd render any css that comes after it.

My apologies for the late response.

no-response[bot]November 26, 20180 reactions

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

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.