jStyleParser is a quite useful tool and am very happy that it exists. Have been playing with it and learning a lot. Thanks!
That said, I did notice an interesting and potentially significant bug.
It seems in some cases, jStyleParser evaluates CSS classes based on the order they are in and can miss if an element has multiple classes that modify the same property.
I researched it a bit and found that the order of the classes should not matter, rather it should go by which style rule comes later in the .css file.
For instance, let’s say you have <div class ="red blue">
. The red CSS style has {color:red;}
and the blue has {color: blue;}
. As is, the div will always be parsed as being red because it came first.
But the correct interpretation is, I believe, that it should be blue if the blue style rule comes later in the css.
This can be particularly significant with widths as shown below in a test case I came up with:
HTML file
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="/testing/test.css">
</head>
<body>
<div class = "coltypea coltypeb"> Lorem ipsum <p class = "blue red"> test</p></div>
</body>
</html>
CSS File
.coltypea {width: 90%;}
.coltypeb {width: 10%;}
.red {font-size: 50px;}
.blue{font-size:12px;}
With this code, the potential bug can be seen in that both Firefox and Chrome interpret the width of the <div class = "coltypea coltypeb">
element to be 10% as that definition comes later in the CSS.
jStyleParser, however, seems to think that element has a width of 90%.
Not sure if it matters, but I am using TagSoup instead of NekoHTML to parse the HTML code.