AngleSharp / AngleSharp.Css

:angel: Library to enable support for cascading stylesheets in AngleSharp.
https://anglesharp.github.io
MIT License
72 stars 34 forks source link

Grid Area wrong parsed #85

Closed jogibear9988 closed 2 years ago

jogibear9988 commented 2 years ago

Bug Report

Prerequisites

For more information, see the CONTRIBUTING guide.

Description

Grid area is converted to wrong css

Steps to Reproduce

Try this snippet:

        var source = "#nav-header {grid-area: navheader; }";
        var css = ParseStyleSheet(source);
        var text = css.Rules[0].CssText;

Expected behavior: [What you expected to happen]

I expect the text to be the same as in source (or nearly)

Actual behavior: [What actually happened]

the text look like this:

   #nav-header { grid-area: navheader / navheader / auto / auto }

problem is, this text renders the html differently then the original one (at least in chrome)

jogibear9988 commented 2 years ago

If you do this in Chrome:

  $0.style.gridArea="bb"
  window.getComputedStyle($0).gridRowEnd
  window.getComputedStyle($0).gridColEnd

you get "bb" for both of the values. AngleSharp set's them to "auto"

jogibear9988 commented 2 years ago

I can fix this by adding

            if (tuple.Items.Length > 0)
            {
                return tuple.Items[0];
            }

to this method:

https://github.com/AngleSharp/AngleSharp.Css/blob/e549e0bf8a71426a4b01ab4a65549ae8ee0e6bd3/src/AngleSharp.Css/Declarations/GridAreaDeclaration.cs#L65

before that line:

  return new Constant<Object>(CssKeywords.Auto, null);

but I don't know how to fix the minification correctly.

I think in the Merge if all 4 values are the same, they should be merged back to one.