-
Notifications
You must be signed in to change notification settings - Fork 144
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
[TASK] Remove the IE hack in Rule
#995
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#993 deprecated this functionality in the 8,x branch, so we can remove it for 9.0 (provided we do actually release 8.8 first). However, one deprecation was missing from that change. (And a private
property was unnecessarily deprecated.)
Also, if we remove support for IE hacks, we should not then allow CSS rules containing them to be parsed as valid.
src/Rule/Rule.php
Outdated
if ($parserState->getSettings()->bLenientParsing) { | ||
while ($parserState->comes('\\')) { | ||
$parserState->consume('\\'); | ||
$rule->addIeHack($parserState->consume()); | ||
$parserState->consume(); | ||
$parserState->consumeWhiteSpace(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this whole code block is parsing the IE hack(s). And the idea is that IE will treat them as valid rules whilst other browsers will discard them. There's a mention in the readme that IE hacks are only supported in lenient mode. So, on that basis, I think the entire if
statement should be removed, so that invalid declarations with IE hacks are discarded rather than kept.
1422ea1
to
7448857
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still isn't quite right, but I'm not sure why. The rules with IE hacks should be dropped entirely (in lenient mode when an exception is not thrown).
If only the IE hack part of the value is dropped, the result is a property declaration that all browsers would apply. Whereas with the IE hack, it is only applied in IE.
The removed code was the only IE-hack-specific code I could find. My best guess ist that the rest is from "the way lenient parsing currently works". I'd like to keep this PR focused on removing these specific pieces of code, and keep "cleaning up lenient parsing" out of it. I'm aiming for "remove what I can find about our special cases for IE hacks without breaking anything", not for "add a feature to clean up and remove IE hacks in the input CSS". @JakeQZ Would this be okay for you? |
7448857
to
706bf32
Compare
I have changed the name of the test from |
706bf32
to
1d0a737
Compare
I think you're right. Rule::parse() will return a valid
I'm not sure about this rename - the IE hacks seem to be all removed - things like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rules with IE hacks should be dropped entirely (in lenient mode when an exception is not thrown).
The removed code was the only IE-hack-specific code I could find. My best guess ist that the rest is from "the way lenient parsing currently works".
I managed to unearth the change that introduced the IE hacks: e1ecb78
There are two additional changes I can see that also need to be undone.
Value::parseValue()
has the responsibility of continually parsing until it finds something that terminates the value, like;
,}
or!
(for!important
). There it is also testing for\
for the IE hacks. So that conditional should be removed. Then we might find the rules with IE hacks are dropped as they should be (and would be by non-IE browsers).- If the above so far is good, the test method in lenient mode can be renamed to indicate that rules with IE hacks will be discarded.
ParserState::parseCharacter
has special-case handling of\0
and\9
which should also be removed.
I am not sure why Value::parseValue()
is also stopping at )
. I have a vague recollection of that also being used in an IE hack. However, the Rule
class doesn't appear to support that as an IE hack (if it ever did), and that was already in place before the IE hack support was added. That's beyond the scope of this PR.
1d0a737
to
a41aff5
Compare
I have removed the other IE-hacks-related code parts now. I've also removed the tests as we now don't have a special case anymore (and I failed to create a usable expected string to compare with). |
a41aff5
to
f2ff2d2
Compare
Could you not just run the tests and capture the (unexpected) output, then paste that in as the expected output? Having the tests in place was a massive help in working out what wasn't quite working, since you had changed the expected result to match the result after the code change. Having that there saved any actual debugging, as it made it possible to work out what was going on by merely inspecting the code and looking at the output (in the tests). So, for this PR, I would not like the tests removed, because I would like to see the result of the changes in the tests to confirm it is A-OK. The tests can be dropped in a subsequent PR. Does that work for you? |
I tried … and failed to copy'n'paste the actual output as it contained at least a tab and a non-displayable character. Would you be willing to give it a go (after I've rebase this PR and resolved the merge conflicts)? |
6b78510
to
b5dc33b
Compare
I'll give it a try later. But I am using Windows :/ |
If you get stuck, please let me know. Then I'll try again. |
4e7ba3b
to
0e1570a
Compare
I've got a bit further with this. With IE hacks support removed, |
0e1570a
to
c778cfa
Compare
c778cfa
to
b0c8d8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added #1053 to capture the issues found.
We can now remove those tests.
Actually they do as direct values, though not in arguments to functions like |
No description provided.