Skip to content

Commit 08010a2

Browse files
authored
[TASK] Remove the IE hack in Rule (#995)
1 parent 54ca442 commit 08010a2

File tree

7 files changed

+1
-90
lines changed

7 files changed

+1
-90
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Please also have a look at our
4040

4141
### Removed
4242

43+
- Remove the IE hack in `Rule` (#995)
4344
- Drop `getLineNo()` from the `Renderable` interface (#1038)
4445
- Remove `OutputFormat::level()` (#874)
4546
- Remove expansion of shorthand properties (#838)

config/phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,6 @@ parameters:
234234
count: 1
235235
path: ../src/Rule/Rule.php
236236

237-
-
238-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
239-
identifier: empty.notAllowed
240-
count: 1
241-
path: ../src/Rule/Rule.php
242-
243237
-
244238
message: '#^Only booleans are allowed in an if condition, Sabberworm\\CSS\\Value\\RuleValueList\|string\|null given\.$#'
245239
identifier: if.condNotBoolean
@@ -258,12 +252,6 @@ parameters:
258252
count: 1
259253
path: ../src/Rule/Rule.php
260254

261-
-
262-
message: '#^Parameters should have "string" types as the only types passed to this method$#'
263-
identifier: typePerfect.narrowPublicClassMethodParamType
264-
count: 1
265-
path: ../src/Rule/Rule.php
266-
267255
-
268256
message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:comments\(\)\.$#'
269257
identifier: method.notFound

src/Parsing/ParserState.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,6 @@ public function parseIdentifier($ignoreCase = true)
150150
public function parseCharacter($isForIdentifier)
151151
{
152152
if ($this->peek() === '\\') {
153-
if (
154-
$isForIdentifier && $this->parserSettings->usesLenientParsing()
155-
&& ($this->comes('\\0') || $this->comes('\\9'))
156-
) {
157-
// Non-strings can contain \0 or \9 which is an IE hack supported in lenient parsing.
158-
return null;
159-
}
160153
$this->consume('\\');
161154
if ($this->comes('\\n') || $this->comes('\\r')) {
162155
return '';

src/Rule/Rule.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ class Rule implements Renderable, Commentable
3636
*/
3737
private $isImportant = false;
3838

39-
/**
40-
* @var array<int, int>
41-
*/
42-
private $ieHack = [];
43-
4439
/**
4540
* @var int
4641
*/
@@ -91,13 +86,6 @@ public static function parse(ParserState $parserState): Rule
9186
$parserState->consume(':');
9287
$value = Value::parseValue($parserState, self::listDelimiterForRule($rule->getRule()));
9388
$rule->setValue($value);
94-
if ($parserState->getSettings()->usesLenientParsing()) {
95-
while ($parserState->comes('\\')) {
96-
$parserState->consume('\\');
97-
$rule->addIeHack($parserState->consume());
98-
$parserState->consumeWhiteSpace();
99-
}
100-
}
10189
$parserState->consumeWhiteSpace();
10290
if ($parserState->comes('!')) {
10391
$parserState->consume('!');
@@ -220,30 +208,6 @@ public function addValue($value, $type = ' '): void
220208
}
221209
}
222210

223-
/**
224-
* @param int $modifier
225-
*/
226-
public function addIeHack($modifier): void
227-
{
228-
$this->ieHack[] = $modifier;
229-
}
230-
231-
/**
232-
* @param array<int, int> $modifiers
233-
*/
234-
public function setIeHack(array $modifiers): void
235-
{
236-
$this->ieHack = $modifiers;
237-
}
238-
239-
/**
240-
* @return array<int, int>
241-
*/
242-
public function getIeHack()
243-
{
244-
return $this->ieHack;
245-
}
246-
247211
/**
248212
* @param bool $isImportant
249213
*/
@@ -276,9 +240,6 @@ public function render(OutputFormat $outputFormat): string
276240
} else {
277241
$result .= $this->value;
278242
}
279-
if (!empty($this->ieHack)) {
280-
$result .= ' \\' . \implode('\\', $this->ieHack);
281-
}
282243
if ($this->isImportant) {
283244
$result .= ' !important';
284245
}

src/Value/Value.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public static function parseValue(ParserState $parserState, array $aListDelimite
5050
while (
5151
!($parserState->comes('}') || $parserState->comes(';') || $parserState->comes('!')
5252
|| $parserState->comes(')')
53-
|| $parserState->comes('\\')
5453
|| $parserState->isEnd())
5554
) {
5655
if (\count($aStack) > 0) {

tests/ParserTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,28 +1036,6 @@ public function unexpectedTokenExceptionLineNo(): void
10361036
}
10371037
}
10381038

1039-
/**
1040-
* @test
1041-
*/
1042-
public function ieHacksStrictParsing(): void
1043-
{
1044-
$this->expectException(UnexpectedTokenException::class);
1045-
1046-
// We can't strictly parse IE hacks.
1047-
self::parsedStructureForFile('ie-hacks', Settings::create()->beStrict());
1048-
}
1049-
1050-
/**
1051-
* @test
1052-
*/
1053-
public function ieHacksParsing(): void
1054-
{
1055-
$document = self::parsedStructureForFile('ie-hacks', Settings::create()->withLenientParsing(true));
1056-
$expected = 'p {padding-right: .75rem \\9;background-image: none \\9;color: red \\9\\0;'
1057-
. 'background-color: red \\9\\0;background-color: red \\9\\0 !important;content: "red \\0";content: "red઼";}';
1058-
self::assertSame($expected, $document->render());
1059-
}
1060-
10611039
/**
10621040
* @depends files
10631041
*

tests/fixtures/ie-hacks.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)