Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
quick fix (!important keyword support for color)
Browse files Browse the repository at this point in the history
  • Loading branch information
p1ho committed Dec 18, 2019
1 parent 7dfcae2 commit 9ef47fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/ColorContrast/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ private function _get_style_properties(string $style_str, string $tag_name, $par

if (isset($styles_raw[$property])) {
$value = $styles_raw[$property];

if (strpos($value, '!important') !== false) {
$value = trim(str_replace('!important', '', $value));
}
if ($this->_is_color_function($value)) {
$child_color_array = $this->_color_function_to_array($value);
$this->parent_true_font_color = $child_color_array;
Expand Down
14 changes: 10 additions & 4 deletions tests/ColorContrast/CheckerTestcases/testcases_basic_html_pass.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@
// !important keyword should still be acceptable
new testcase(
'
<p style="background-color: white !important;">should pass</p>
<p style="background-color: rgb(255, 255, 255) !important;">should pass</p>
<p style="background-color: rgba(255, 255, 255, .8) !important;">should pass</p>
<p style="background-color: #fff !important;">large text should pass</p>
<p style="background-color: white !important; color: black !important;">should pass</p>
<p style="background-color: rgb(255, 255, 255) !important; color: rgb(0, 0, 0) !important;">should pass</p>
<p style="background-color: rgba(255, 255, 255, .8) !important; color: rgba(0, 0, 0, 1) !important;">should pass</p>
<p style="background-color: #fff !important; color: #000 !important;">should pass</p>
<p style="background-color: transparent !important; color: initial !important;">should pass</p>
<p style="background: white !important;">should pass</p>
<p style="background: rgb(255, 255, 255) !important;">should pass</p>
<p style="background: rgba(255, 255, 255, .8) !important;">should pass</p>
<p style="background: #fff !important;">should pass</p>
<p style="background: transparent !important;">should pass</p>
',
array('passed'=>true,'errors'=>array())
),
Expand Down

0 comments on commit 9ef47fb

Please sign in to comment.