See #1675894: Make calendar flexible and responsive where we tried to make the layout flexible and responsive.

Example code:

  .calendar-calendar .month-view .full tr td.single-day:before { 
    content: attr(data-day-of-month) ", " attr(headers); 
    font-weight: bold;
  }

Results in compressed CSS code with the space removed in ",".

We should not optimize content at all or correct it with unicode representations like \0000a0 to prevent this.

Related:
#1741498: Add a responsive preview bar to Drupal core
#936316: CSS aggregation strips some essential whitespace within strings

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Component: base system » CSS
bkonetzny’s picture

Identified the problem in drupal_load_stylesheet_content() in the following line:

# Strip leading and trailing whitespace.
\s*([@{};,])\s*

This code removes whitespace before and after "@{};,", so fine for regular css, but not for content with @{};, and spaces around it. Content without @{};, will work fine right now.

bkonetzny’s picture

Status: Active » Needs review
FileSize
1.33 KB

Attached patch for drupal 7 where content declarations are extracted and saved before whitespace cleanup and inserted afterwards.

Status: Needs review » Needs work

The last submitted patch, drupal-css_content_attribute-1686178-3.patch, failed testing.

hass’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs work » Needs review

I think it would be a lot easier if we only replace the spaces with the unicode value \0000a0.

hass’s picture

Status: Needs review » Needs work
Issue tags: +Needs backport to D6, +Needs backport to D7

The last submitted patch, drupal-css_content_attribute-1686178-3.patch, failed testing.

hass’s picture

Version: 7.x-dev » 8.x-dev
hass’s picture

Issue summary: View changes

a

hass’s picture

Issue summary: View changes

A

mikeytown2’s picture

Played around with this a little bit in #2067249: Add in the ability for the CSS content attribute to be translated. and I would change the preg_replace_callback so that it doesn't use an anonymous function. Also the content regex doesn't match the example given in the Issue Summary. Following regex will match /content:.*?($double_quot|$single_quot).*?(?:\\;|\\})/.

mikeytown2’s picture

Issue summary: View changes

A

John_B’s picture

Issue summary: View changes

There seems to be a problem with the string ), in selectors. In D7 the aggregator breaks ul:not(.contextual-links), body etc, selectors following the comma are lost.

Anybody’s picture

What can we do here to take this forward?
This problem occurs again and again and leads to subsequent problems like #2511524: Add a setting to turn on / off css "optimizing".

Wim Leers’s picture

Component: CSS » asset library system

Write a test that causes failures. Then add the fix and show the new test no longer fails.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Anonymous’s picture

#936316: CSS aggregation strips some essential whitespace within strings solved this problem.

Before aggregation:

.calendar-calendar .month-view .full tr td.single-day:before { 
    content: attr(data-day-of-month) ", " attr(headers); 
    font-weight: bold;
  }

After aggregation:
.calendar-calendar .month-view .full tr td.single-day:before{content:attr(data-day-of-month) ", " attr(headers);font-weight:bold;}

Anonymous’s picture

Status: Needs work » Closed (duplicate)