go-css icon indicating copy to clipboard operation
go-css copied to clipboard

parser: unexpected behaviour when more than 1 block

Open gucio321 opened this issue 3 years ago • 2 comments

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...

gucio321 avatar Sep 27 '22 18:09 gucio321

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...

gucio321 avatar Sep 27 '22 18:09 gucio321

well, I suppose whats the bug... There is a missing continue statement at the end of ghis if statement.

gucio321 avatar Sep 27 '22 18:09 gucio321