mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-27 22:33:10 +09:00
Add parser for IE conditional comments, to be used in JS concatenation
This commit is contained in:
parent
e22558374f
commit
90bce20794
3 changed files with 132 additions and 1 deletions
|
|
@ -131,4 +131,33 @@ class FormatterTest extends \Codeception\TestCase\Test
|
|||
|
||||
unlink($test_target);
|
||||
}
|
||||
|
||||
public function testConvertIECondition()
|
||||
{
|
||||
$this->assertEquals('window.navigator.userAgent.match(/MSIE\s/)', Rhymix\Framework\Formatter::convertIECondition('IE'));
|
||||
$this->assertEquals('!window.navigator.userAgent.match(/MSIE\s/)', Rhymix\Framework\Formatter::convertIECondition('!IE'));
|
||||
$this->assertEquals('!window.navigator.userAgent.match(/MSIE\s/)', Rhymix\Framework\Formatter::convertIECondition('!(IE)'));
|
||||
$this->assertEquals('true && false', Rhymix\Framework\Formatter::convertIECondition('true&false'));
|
||||
$this->assertEquals('false', Rhymix\Framework\Formatter::convertIECondition('gobbledygook'));
|
||||
|
||||
$source = 'gt IE 7';
|
||||
$target = '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] > 7)';
|
||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
||||
|
||||
$source = 'lte IE 8';
|
||||
$target = '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] <= 8)';
|
||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
||||
|
||||
$source = '(gte IE 6) & (lt IE 8)';
|
||||
$target = '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] >= 6) && (/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 8)';
|
||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
||||
|
||||
$source = '!(gt IE 9)';
|
||||
$target = '!(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] > 9)';
|
||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
||||
|
||||
$source = '!lt IE 8|lt IE 6';
|
||||
$target = '!(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 8) || (/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 6)';
|
||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue