go-css
go-css copied to clipboard
parser: unexpected behaviour when more than 1 block
Hi ther! I'm trying to parse CSS using the library. the problem is, that If I use more than 1 block, the value of the previously parsed rules are getting overwriten. I'm investigating this issue now, and I'm sure that it is something with go's maps... They are probably a pointers and the same pointer is being assigned...
okey, its the other problem. What is this code intended to do???
for i := range rule {
oldRule, ok := css[Rule(rule[i])]
if ok {
// merge rules
for style, value := range oldRule {
if _, ok := styles[style]; !ok {
styles[style] = value
}
}
}
css[Rule(rule[i])] = styles
}
https://github.com/napsy/go-css/blob/b251a459e17c9393099f7fd72401bab32da36937/parser.go#L191
it actually seems to break the parser...
well, I suppose whats the bug... There is a missing continue statement at the end of ghis if statement.