• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Style property: unit handling error

Arty

Well-known member
#1
When editing style properties via WebDav, if background position value is 0 and it has units, XenForo considers whole background statement invalid.

Example

This line is parsed correctly:
Code:
background: transparent url('@imagePath/xenforo/xenforo-ui-sprite.png') no-repeat -64px 0;
But when using this line:
Code:
background: transparent url('@imagePath/xenforo/xenforo-ui-sprite.png') no-repeat -64px 0px;
XenForo considers it invalid and adds -xenforo-nomatch- prefix.

Bigger chunk of test code:

Save the following data via WebDav:
Code:
        @property "arrowWidget";
        background: transparent url('@imagePath/xenforo/xenforo-ui-sprite.png') no-repeat -64px 0px;
        width: 14px;
        @property "/arrowWidget";
then reload css template. That code will look like this:
Code:
        @property "arrowWidget";
        width: 14px;
        @property "/arrowWidget";
    -xenforo-nomatch-background: transparent url('@imagePath/xenforo/xenforo-ui-sprite.png') no-repeat -64px 0px;
 
#2
ok, thanks:D
very confusing, i had to play many hours around that problem
to figure out that css line will be automaticly replaced with xenforo-nomatch
 

Jake Bunce

XenForo moderator
Staff member
#4
Confirmed.

Code fix to add optional units to the 0 value:

library/XenForo/Model/StyleProperty.php

Add the red code:

Code:
			else if (preg_match('/^(
					(
						(left|center|right|0(%|[a-z]+)?|-?\d+(\.\d+)?(%|[a-z]+))
						(
							\s+(top|center|bottom|0(%|[a-z]+)?|-?\d+(\.\d+)?(%|[a-z]+))
						)?
					)|top|center|bottom
				)/ix', $value, $match))
			{
				if (isset($output['background-position']))
				{
					return false;
				}
				$output['background-position'] = $match[0];
			}