Skip to content

Shorthands - closes #29 #30

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

Closed
wants to merge 3 commits into from
Closed

Shorthands - closes #29 #30

wants to merge 3 commits into from

Conversation

ju1ius
Copy link

@ju1ius ju1ius commented Sep 22, 2011

I had to change the implementation of CSSRuleSet.
The rules list is now a numerically indexed array instead of an associative array.
This allows us to have things like this:

p {
  border-style: solid !important;
  foobar: baz;
  border-style: none;
}

And then do this:

foreach($oRuleSet->getRules('border-style') as $position => $rule) {
  printf("%d => %s", $position, $rule);
}
/*
0 =>  border-style: solid !important;
2 => border-style: none;
*/
echo $oRuleSet->getAppliedRule('border-style');
/*
border-style: solid !important;
*/

This allows expand/createShorthands to get around some edge cases.

@sabberworm
Copy link
Collaborator

I don’t know what I was thinking when I implemented CSSRuleSet as an associative array; I should have thought of vendor-specific values and the !important flag. I would still, however, like to stick with the existing API as closely as possible, e.g. passing ('font-') instead of ('font', true) to removeRule and getRule (and revert the name change from removeRule to remove).

$aResult = array();
foreach($this->aRules as $iPos => $oRule) {
if($bWildcard) {
if(strpos($oRule->getRule(), $mRule) === 0) $aResult[$iPos] = $oRule;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would also return textism: none when asked for ('text', true) where the old code would not when asked for ('text-').

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