Skip to content
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

Add a failing test case for & within a nested function in a declaration value #307

Merged
merged 2 commits into from
Apr 26, 2023

Conversation

Andarist
Copy link
Collaborator

stylis(`
background-image: image-set(url(${urlOneX}) 1x, url(${urlTwoX}) 2x);
`)
).to.equal(`.user{background-image:image-set(url(${urlOneX}) 1x, url(${urlTwoX}) 2x);}`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\f gets incorrectly appended to & here:

stylis/src/Parser.js

Lines 47 to 49 in bc0b1b0

if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f') != -1)
ampersand = -1
break

I'd like to conditionally use this replace here - we need to skip it when we are in the context of the property. I've tried to use property for this and while I managed to fix this case I broke some other cases like this one:

stylis/test/Parser.js

Lines 593 to 601 in bc0b1b0

test('pseudo-selector with & in a string', () => {
expect(
stylis(`
h1:matches(&,[href="https://css-tricks.com?a=1&b=2"]) {
display: none
}
`)
).to.equal(`h1:matches(.user,[href="https://css-tricks.com?a=1&b=2"]){display:none;}`)
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thysultan friendly 🏓

@github-actions
Copy link

Pull Request Test Coverage Report for Build 673315f00359b3ae65949786d475d88332f8149d-PR-307

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 98.849%

Totals Coverage Status
Change from base Build bc0b1b03f5562eb8b38601e4e05461631a91c400: 0.006%
Covered Lines: 271
Relevant Lines: 273

💛 - Coveralls

@thysultan
Copy link
Owner

@Andarist didn't notice this when you opened it, (only the friendly ping): fixed in the head commit, you can merge/release this one.

@Andarist Andarist merged commit d28ad01 into master Apr 26, 2023
2 checks passed
@Andarist Andarist deleted the ampersand-in-value branch April 26, 2023 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants