jamietre / CsQuery

CsQuery is a complete CSS selector engine, HTML parser, and jQuery port for C# and .NET 4.
Other
1.15k stars 249 forks source link

Css() is not removing style on empty value string #93

Closed cmwoods closed 11 years ago

cmwoods commented 11 years ago

Specifying an empty string for a property is yielding incorrect rendering/output in CsQuery:

dom.Select("tr").Css("height", ""):

results in:

...<tr style="height: ">...

in the HTML rendering.

According to api.jquery.com:

Setting the value of a style property to an empty string — e.g. $('#mydiv').css('color', '') — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or <style> element. Warning: one notable exception is that, for IE 8 and below, removing a shorthand property such as border or background will remove that style entirely from the element, regardless of what is set in a stylesheet or <style> element.

[The latter portion is not currently applicable because CsQuery does not apply stylesheets/<style> element from the header to the nodes.]