Skip to content
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

Loading content from a string truncates decimal percentages values in keyframes. #128

Closed
5 tasks done
mbce opened this issue Jan 16, 2023 · 1 comment
Closed
5 tasks done
Labels
Milestone

Comments

@mbce
Copy link

mbce commented Jan 16, 2023

Bug Report

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Description

First of all hello, and thank you very much for your wonderful library :)
I am having an issue with serializing HTML+CSS Content, as described in the title:

If I load an html string into a document (BrowsingContext.New(Configuration.Default.WithCss()), context.OpenAsync...) with a style tag in the head, describing different animations thanks to the @Keyframes rule, using decimal component in percentages (0.14% { ... } for instance), the decimal part of my keyframe percentage is removed as soon as I serialize this document again (document.ToHtml()).

According to CSS Documentation, percentages are numbers (https://www.w3.org/TR/css3-values/#percentages), so I suppose this integer conversion should not happen, am I wrong here ?
So, I looked at several places, the FAQ, documentation and so on, and I couldn't find something to help me, but if I missed it, I apologize in advance :)

Steps to Reproduce

  1. Create an HTML document with style inside the head.
  2. Create a keyframes rule with decimal component in the percentage values {@Keyframes 27.32% { ... } }
  3. Take this HTML as a string
  4. Load this string into an AngleSharp document, creating the context with css.
  5. Serialize this document
  6. Look at the obtained string

Expected behavior:
The serialized string should contain the same rule as the source, with the decimal percentage.

Actual behavior:
The serialized string has the percentage value truncated, removing its decimal component (it becomes {@Keyframes 27% { ... } })

Environment details:

  • Windows 10 & Ubuntu
  • .NET5 project
  • AngleSharp 1.0.1
  • AngleSharp.css 0.17.0

Possible Solution

I don't know, maybe the type used when parsing the value internally should be changed ?

Thank you very much :)

@mbce mbce added the bug label Jan 16, 2023
@FlorianRappl FlorianRappl added this to the v1.0 milestone Jun 14, 2023
@FlorianRappl
Copy link
Contributor

Implemented and part of next preview / 1.0.0.

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

No branches or pull requests

2 participants