Skip to content

CSS shorthand property **text-decoration** is not properly expanded #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
atlastodor opened this issue May 28, 2019 · 4 comments
Closed
Milestone

Comments

@atlastodor
Copy link

Bug Report

Prerequisites

  • [ Yes ] Can you reproduce the problem in a [MWE]
  • [ Yes 0.12.1 ] Are you running the latest version of AngleSharp?
  • [ Yes ] Did you check the FAQs to see if that helps you?
  • [ Yes ] Are you reporting to the correct repository? (if its an issue with the core library, please report to AngleSharp directly)
  • [ Yes ] Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Description

CSS shorthand property text-decoration is not properly expanded.

Steps to Reproduce

  1. Configure AngleSharp WithCss.
  2. Using a new BrowsingContext, parse this HTML:
<!DOCTYPE html>
<html>
<head><title></title></head>
<body style="text-decoration: underline dotted;"></body>
</html>
  1. Get the style for the Body element.
    var styleDeclaration = document.Body.ComputeCurrentStyle();

Expected behavior:
As per CSS text-decoration

<'text-decoration-line'> || <'text-decoration-style'> || <'text-decoration-color'>.

"text-decoration-style: dotted"
"text-decoration-line: underline"

Actual behavior:

"text-decoration-style: underline"
"text-decoration-line: dotted"

Environment details:
Windows 10, .Net 4.7

Possible Solution

Swap so text-decoration-style is expanded into text-decoration-line and vice-versa.

PS: When you are changing CSS properties behavior, could you please override the ToString() method to return the CssText. This will make working in the debugger much easier.

@FlorianRappl
Copy link
Contributor

Thanks for the report. I'll look into it.

PS: When you are changing CSS properties behavior, could you please override the ToString() method to return the CssText. This will make working in the debugger much easier.

Unfortunately, this was one of the original designs and it has many pitfalls. What I can recommend is either working with some auto variables or something like OzCode.

Just for debugging reasons ToString should not be overridden. Instead, DebuggerDisplayAttribute could be used in such cases (which was already used in AngleSharp in earlier versions; but as explained we discarded that). One of the reasons not to use it in AngleSharp (and AngleSharp.Css) is that this output (W3C serialization) may be confusing at times and does not tell the whole story (e.g., two classes may be have the same serialization).

@FlorianRappl FlorianRappl added this to the v0.13 milestone May 28, 2019
FlorianRappl added a commit that referenced this issue May 28, 2019
@FlorianRappl
Copy link
Contributor

Landed in devel.

@atlastodor
Copy link
Author

Just for debugging reasons ToString should not be overridden. Instead, DebuggerDisplayAttribute could be used in such cases (which was already used in AngleSharp in earlier versions; but as explained we discarded that). One of the reasons not to use it in AngleSharp (and AngleSharp.Css) is that this output (W3C serialization) may be confusing at times and does not tell the whole story (e.g., two classes may be have the same serialization).

OK. I understand. Normally when I need such a thing, my method will return something like:
ToString() => this.GetType().Name + ": " + this.MyName;
… so that the object can easily be debugged, but users won't confuse ToString with something returning useful information.

@FlorianRappl
Copy link
Contributor

This sounds like a great strategy @atlastodor. I guess we could do something like this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants