-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX] Wrong selector extraction from minified CSS #69
Conversation
public function emogrifyMinifiedCss() { | ||
$html = self::HTML5_DOCUMENT_TYPE . self::LF . '<html><p></p></html>' . self::LF; | ||
$this->subject->setHtml($html); | ||
$this->subject->setCss('html{color:blue;}html,h1,.class{color:red;}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you reduce the CSS test data to a minimum that still has the problem? Currently, I do not see what the exact problem is: two selectors, or no spaces, or two rules for the same property?
Maybe you can also change the test name to show what the exact case is.
In the commit message: css -> CSS |
See var_dump of $matches on line 308
Second selector it's just |
$this->subject->setCss('html{color:blue;}html{color:red;}'); | ||
|
||
$this->assertContains( | ||
'style="color:red;"', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have the element name here in the assertContains.
done |
public function emogrifyCanMatchMinifiedCss() { | ||
$html = self::HTML5_DOCUMENT_TYPE . self::LF . '<html><p></p></html>' . self::LF; | ||
$this->subject->setHtml($html); | ||
$this->subject->setCss('html{color:blue;}html{color:red;}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have two different properties here (or even better: two different element names) so that we don't test attribute overriding ("the last one wins") or "two attributes for one element" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And let's have two tests: One for the first selector and one for the second/last selector.
we need there have two elements in minified CSS - that's the point first one match well second not match at all what about
Will be enough? |
Yes, that would be perfect. |
it's there |
Emogrifier have problem with minified CSS code
First character from first selector is lost: