[v4] Support old important modifier position (#13103)

* Support old important modifier position

* update

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
This commit is contained in:
Adam Wathan 2024-03-06 10:56:56 -05:00 • committed by GitHub
parent 19fcd0ebba
commit b3b2debdd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View file

@ -269,6 +269,12 @@ export function parseCandidate(
base = base.slice(0, -1)
}
// Legacy syntax with leading `!`, e.g. `!mx-4`.
else if (base[0] === '!') {
state.important = true
base = base.slice(1)
}
// Arbitrary properties
if (base[0] === '[') {
let [baseWithoutModifier, modifierSegment = null] = segment(base, '/')

View file

@ -341,6 +341,14 @@ describe('important', () => {
`)
})
it('should generate an important utility with legacy syntax', () => {
expect(run(['!underline'])).toMatchInlineSnapshot(`
".\\!underline {
text-decoration-line: underline !important;
}"
`)
})
it('should not mark declarations inside of @keyframes as important', () => {
expect(
compileCss(