Skip to content

Conversation

@raxbg
Copy link
Contributor

@raxbg raxbg commented Jun 28, 2018

Fixes issue #79

Copy link
Collaborator

@sabberworm sabberworm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your work!
Could you take a look at the issues I raised?

}

private function parseCalcValue() {
$func = $this->comes('calc', true) ? 'calc' : '-webkit-calc';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use $func = trim(consumeUntil('(')) to streamline this.

$oValue = $this->parseColorValue();
} else if ($this->comes('url', true)) {
$oValue = $this->parseURLValue();
} else if ($this->comes('calc', true) || $this->comes('-webkit-calc', true)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support -moz-calc as well. Also, is there an -o-calc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for -moz-calc, but -o-calc does not seem to exist https://www.w3schools.com/cssref/func_calc.asp

$this->consume($func);
$this->consumeWhiteSpace();
$this->consume('(');
$aArguments = $this->parseValue(array('+', '-', '*', '/', ' '), '\Sabberworm\CSS\Value\CalcRuleValueList');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing the arguments using parseValue probably means an expression like calc(50% -8px) would be treated as calc(50% - 8px), not as an error (like it should).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in assuming that this does not support parenthesized subexpressions like calc( ( 100px / 2) / 2)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct for both. Should be fixed now :)

public $sSpaceAfterListArgumentSeparator = '';

// This is what’s printed after the operators in a calc function
public $sSpaceBeforeCalcListArgumentSeparator = ' ';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the spaces around - and + operators are mandatory, their output should not be affected by OutputFormat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I removed this entirely in the last commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants