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

Bug in optimizePart function #82

Open
qmegas opened this issue Jul 31, 2023 · 0 comments
Open

Bug in optimizePart function #82

qmegas opened this issue Jul 31, 2023 · 0 comments

Comments

@qmegas
Copy link

qmegas commented Jul 31, 2023

When some specific element have few classes in the selector, then optimization cause an error.

For example,

Let's say that full path looks like that: .first-elem >.second-elem.another-class >.last-elem

When optimizePart called with following arguments:

prePart = .someSelector
current = >.second-elem.another-class
postPart = > .last-elem

So when class optimisation starts to work

if (/\.\S+\.\S+/.test(current)) {

Let's say it removes part .second-elem from the selector and full selector still works fine, then it tries to remove the second class too, which creates incorrect selector like that: .first-elem > >.last-elem which cause an error when calling this line

var matches = document.querySelectorAll(pattern)

qmegas added a commit to qmegas/optimal-select that referenced this issue Jul 31, 2023
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

No branches or pull requests

1 participant