Skip to content

Commit

Permalink
Merge branch 'MDL-45545-26' of git://github.com/FMCorz/moodle into MO…
Browse files Browse the repository at this point in the history
…ODLE_26_STABLE
  • Loading branch information
danpoltawski committed May 20, 2014
2 parents e77dcc6 + e505b12 commit 67f6eba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/csslib.php
Expand Up @@ -203,9 +203,9 @@ function css_chunk_by_selector_count($css, $importurl, $maxselectors = 4095, $bu
}
}

// Let's count the number of selectors, but only if we are not in a rule as they
// can contain commas too.
if (!$inrule && $char === ',') {
// Let's count the number of selectors, but only if we are not in a rule, or in
// the definition of a media query, as they can contain commas too.
if (!$mediacoming && !$inrule && $char === ',') {
$selectorcount++;
}

Expand Down
6 changes: 6 additions & 0 deletions lib/tests/csslib_test.php
Expand Up @@ -1176,6 +1176,12 @@ public function test_css_chunking() {
$this->assertCount(1, $chunks);
$this->assertSame('@media (min-width: 980px) { .a,.b{} }', $chunks[0]);

// Test media queries, with commas.
$css = '.a{} @media (min-width: 700px), handheld and (orientation: landscape) { .b{} }';
$chunks = css_chunk_by_selector_count($css, 'styles.php?type=test', 2);
$this->assertCount(1, $chunks);
$this->assertSame($css, $chunks[0]);

// Test special rules.
$css = 'a,b{ background-image: linear-gradient(to bottom, #ffffff, #cccccc);}d,e{}';
$chunks = css_chunk_by_selector_count($css, 'styles.php?type=test', 2);
Expand Down

0 comments on commit 67f6eba

Please sign in to comment.