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

Prefer attribute style selector when an id starts with a digit #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eoghanmurray
Copy link

This is a quick attempt at #67

Apologies I haven't been able to run test cases on my local machine so this might be all worthless.

(can't run tests due to microsoft/TypeScript#51567 )

@@ -356,6 +357,7 @@ function cssesc(string: string, opt: Partial<typeof defaultOptions> = {}) {
}
const quote = options.quotes == 'double' ? '"' : '\''
const isIdentifier = options.isIdentifier
const isId = options.isId
Copy link
Owner

Choose a reason for hiding this comment

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

isId and isIdentifier seems to be very same. Let's rename on or another.

@@ -188,7 +188,7 @@ function id(input: Element): Knot | null {
const elementId = input.getAttribute('id')
if (elementId && config.idName(elementId)) {
return {
name: '#' + cssesc(elementId, {isIdentifier: true}),
name: cssesc(elementId, {isIdentifier: true, isId: true}),
Copy link
Owner

Choose a reason for hiding this comment

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

Also let's add some test for this case.

@pixelpax
Copy link

pixelpax commented Feb 7, 2024

Any movement on this? Still a big problem almost a year later

@antonmedv
Copy link
Owner

Any volunteers to refactor this pr?

@eoghanmurray
Copy link
Author

I really don't know what was meant by isIdentifier ... that it's an id/className/attribute?

I don't see the problem with having them both.

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.

3 participants