optimal-select icon indicating copy to clipboard operation
optimal-select copied to clipboard

Bug in optimizePart function

Open qmegas opened this issue 2 years ago • 0 comments

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 https://github.com/autarc/optimal-select/blob/722d220d2dc54d78121d610a69f6544c2e116721/src/optimize.js#L125

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 https://github.com/autarc/optimal-select/blob/722d220d2dc54d78121d610a69f6544c2e116721/src/optimize.js#L135

qmegas avatar Jul 31 '23 13:07 qmegas