Loading content from a string truncates decimal percentages values in keyframes.
mbce opened this issue · comments
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
- Create an HTML document with style inside the head.
- Create a keyframes rule with decimal component in the percentage values {@Keyframes 27.32% { ... } }
- Take this HTML as a string
- Load this string into an AngleSharp document, creating the context with css.
- Serialize this document
- 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 :)