Skip to content

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

@cmwoods

Description

@cmwoods

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions