andybalholm / cascadia

CSS selector library in Go
BSD 2-Clause "Simplified" License
703 stars 65 forks source link

Attribute Contains (*=) not working #36

Closed fgblomqvist closed 6 years ago

fgblomqvist commented 6 years ago

I am only able to get the attribute contains selector to work for some arbitrary values, not constantly. However, if I switch to the regex selector, it always works like expected.

E.g. this works: [id#=-621-] but not this [id*=-621-] I have tried with smaller portions of that text with the same result. Am I misunderstanding the substring selector? I would think that the above selectors should yield the same result. I'm using goquery, so not directly using cascadia.

The id that I am matching against is: eventLineBook-3139607-238-621-2

andybalholm commented 6 years ago

You need to put quotes around the value ([id*="-621-"]). The part after the equal sign can be either an identifier or a quoted string.

fgblomqvist commented 6 years ago

Ah I see, now it works. Tried single quotes (like in jQuery) but didn't work. Didn't try double quotes until now. Thanks!