Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 4 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,8 @@ on: [push, pull_request]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCS_PATH: ${{ secrets.DOCS_PATH }}
DOCS_BRANCH: ${{ secrets.DOCS_BRANCH }}

jobs:
can_document:
runs-on: ubuntu-latest
outputs:
value: ${{ steps.check_job.outputs.value }}
steps:
- name: Checks whether documentation can be built
id: check_job
run: |
echo "value: ${{ env.DOCS_PATH != null && github.ref == env.DOCS_BRANCH }}"
echo "::set-output name=value::${{ env.DOCS_PATH != null && github.ref == env.DOCS_BRANCH }}"

documentation:
needs: [can_document]
runs-on: ubuntu-latest
if: needs.can_document.outputs.value == 'true'

steps:
- uses: actions/checkout@v5

- name: Use Node.js
uses: actions/setup-node@v5
with:
node-version: "20.x"
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: |
cd $DOCS_PATH
npm install

- name: Deploy Doclet
run: |
cd $DOCS_PATH
npx pilet publish --fresh --url https://feed.piral.cloud/api/v1/pilet/anglesharp --api-key ${{ secrets.PIRAL_FEED_KEY }}

linux:
runs-on: ubuntu-latest

Expand All @@ -56,7 +19,7 @@ jobs:
10.0.x

- name: Build
run: ./build.sh -AngleSharpVersion 1.10.0
run: ./build.sh -AngleSharpVersion 1.11.0

windows:
runs-on: windows-latest
Expand Down Expand Up @@ -87,9 +50,9 @@ jobs:
NUGET_API_KEY: ${{ steps.nuget_login.outputs.NUGET_API_KEY }}
run: |
if ($env:GITHUB_REF -eq "refs/heads/main") {
.\build.ps1 -Target Publish -AngleSharpVersion 1.10.0
.\build.ps1 -Target Publish -AngleSharpVersion 1.11.0
} elseif ($env:GITHUB_REF -eq "refs/heads/devel") {
.\build.ps1 -Target PrePublish -AngleSharpVersion 1.10.0
.\build.ps1 -Target PrePublish -AngleSharpVersion 1.11.0
} else {
.\build.ps1 -AngleSharpVersion 1.10.0
.\build.ps1 -AngleSharpVersion 1.11.0
}
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ dotnet run --project src/AngleSharp.Performance.Css/AngleSharp.Performance.Css.c

Notes:

- CI invokes `./build.sh -AngleSharpVersion 1.10.0` on Linux and `./build.ps1` on Windows.
- CI invokes `./build.sh -AngleSharpVersion 1.11.0` on Linux and `./build.ps1` on Windows.
- Treat warnings as errors is enabled in `src/Directory.Build.props`.

## 3) Build and target framework facts

- Library project: `src/AngleSharp.Css/AngleSharp.Css.csproj`
- Targets: `netstandard2.0;net8.0;net10.0`
- Additional Windows-only targets: `net462;net472`
- The AngleSharp dependency defaults to version `1.10.0` and allows versions below `2.0.0`.
- The AngleSharp dependency defaults to version `1.11.0` and allows versions below `2.0.0`.
- The `net8.0` and `net10.0` targets set `IsAotCompatible`, so trim and AOT analyzer warnings fail the build.
- Test project: `src/AngleSharp.Css.Tests/AngleSharp.Css.Tests.csproj`
- Targets: `net8.0`
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# 1.6.0

Released on Tuesday, November 24 2026.

- Fixed a comment in a declaration's value with a quote in it (e.g. `/* shouldn't */`) starting a string, which swallowed the rest of the style sheet (Acid2)
- Fixed an escaped `}` or `;` in a declaration's value (e.g. `error: \}`) ending the rule
- Fixed a `;` after a rule (e.g. `a { color: red; };`) being skipped instead of making the selector of the next rule invalid, which then applied
- Fixed `! important` with whitespace after the `!` not making the declaration important
- Fixed the `color` media feature, e.g. `(color)` and `(min-color: 0)` not matching, and `monochrome` without a value
- Fixed `not` making a media query with an unknown feature (e.g. `not all and (bogus)`) match
- Fixed `minmax()` with a math function (e.g. `repeat(auto-fill, minmax(min(100%, 17rem), 1fr))`) making `grid-template-columns` invalid in an auto repeat
- Fixed `@scope` rules never applying; a scope root and limit (`@scope (.a) to (.b)`) are respected
- Fixed color hints (e.g. `linear-gradient(black, 20%, white)`) and color interpolation methods (e.g. `in oklch`, `in hsl longer hue`) making a gradient invalid
- Fixed `conic-gradient` with both `from` and `at` being serialized with a comma between them
- Fixed `getComputedStyle` of a shadow host leaving out the `:host` rules of its shadow tree
- Fixed `getComputedStyle` of an element in a shadow tree ignoring the styles of its shadow root and not inheriting from the host
- Fixed `::marker`, `::first-line` and `::first-letter` rules never matching (e.g. for `getComputedStyle(li, '::marker')`)
- Fixed `AppendDefault` of the default style sheet provider dropping what was appended before
- Fixed a closed `details` showing more than its `summary`
- Fixed `transition-property` not accepting custom properties
- Fixed angles being computed in `rad` instead of the canonical `deg`
- Updated minimum version of AngleSharp to 1.11.0
- Added `::part()` styling the parts of shadow trees
- Added the `:modal` pseudo-class and the user agent styles of `dialog`
- Added the `:fullscreen` pseudo-class, which a host forces (`SetPseudoClass`) on the element it shows fullscreen, and its user agent styles
- Added `IAnimatedValueProvider` as the animation origin of the cascade
- Added `GetImageSource()` for `img` elements and `ImageSource` of render nodes
- Added `CssDom.Register`, the DOM of this library declared for a scripting engine

# 1.5.0

Released on Wednesday, November 18 2026.
Expand Down
12 changes: 12 additions & 0 deletions docs/general/05-Extensibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ The dictionary is keyed by the media feature name and holds the keyword the feat

The value is compared to the queried keyword case insensitively, so a keyword that is newer than this library works as well. Used without a value, e.g., `@media (prefers-reduced-motion)`, the feature evaluates in a boolean context, where `no-preference` (and `none` for `forced-colors`, `hover`, `any-hover`, `pointer` and `any-pointer`) is `false`. Without a preference `hover` and `pointer` keep answering as they did before, i.e., as a device with no input mechanism.

## Expose The CSSOM To Scripts Without Reflection

A scripting engine such as AngleSharp.Js finds the CSSOM by reflecting over its DOM attributes by default. A trimmed or natively compiled (AoT) application can instead hand the engine the registration that is generated for this library at build time, `AngleSharp.Css.CssDom.Register` (a `DomRegistration` of AngleSharp). It declares the CSSOM types, the `CSS` namespace and the members the library adds to the DOM, such as `element.style` or `getComputedStyle`:

```cs
var config = Configuration.Default
.WithCss()
.WithJs(CssDom.Register);
```

The registration describes the version of AngleSharp.Css in use, so it never has to be kept in sync by hand. Several libraries are combined with `DomRegistrations.Combine`.

## Composition Pattern

Start from the default registrations and replace only what you need:
Expand Down
28 changes: 0 additions & 28 deletions src/AngleSharp.Css.Docs/docs.config.json

This file was deleted.

58 changes: 0 additions & 58 deletions src/AngleSharp.Css.Docs/package.json

This file was deleted.

7 changes: 0 additions & 7 deletions src/AngleSharp.Css.Docs/src/index.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions src/AngleSharp.Css.Docs/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/AngleSharp.Css.Tests/AngleSharp.Css.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AngleSharp.Xml" Version="1.0.0" />
<PackageReference Include="AngleSharp.Xml" Version="1.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.0" />
Expand Down
27 changes: 27 additions & 0 deletions src/AngleSharp.Css.Tests/Declarations/CssGridProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,33 @@ public void CssGridTemplateColumnsLengthAutoRepeatLengthLegal()
Assert.AreEqual("200px repeat(auto-fill, 100px) 300px", property.Value);
}

[Test]
public void CssGridTemplateColumnsAutoRepeatMinmaxOfMathFunctionLegal()
{
var snippet = "grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr))";
var property = ParseDeclaration(snippet);
Assert.AreEqual("grid-template-columns", property.Name);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("repeat(auto-fill, minmax(min(100%, 17rem), 1fr))", property.Value);
}

[Test]
public void CssGridTemplateColumnsAutoRepeatMinmaxOfCalcLegal()
{
var snippet = "grid-template-columns: repeat(auto-fit, minmax(calc(10rem + 2px), 1fr))";
var property = ParseDeclaration(snippet);
Assert.IsTrue(property.HasValue);
Assert.AreEqual("repeat(auto-fit, minmax(calc(10rem + 2px), 1fr))", property.Value);
}

[Test]
public void CssGridTemplateColumnsAutoRepeatMinmaxWithoutFixedBreadthIllegal()
{
var snippet = "grid-template-columns: repeat(auto-fill, minmax(auto, 1fr))";
var property = ParseDeclaration(snippet);
Assert.IsFalse(property.HasValue);
}

[Test]
public void CssGridTemplateColumnsMultilineLinenamesAutoRepeatLegal()
{
Expand Down
16 changes: 16 additions & 0 deletions src/AngleSharp.Css.Tests/Declarations/CssTransitionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ public void CssTransitionPropertyDashSpecificIllegal()
Assert.IsFalse(property.HasValue);
}

[Test]
public void CssTransitionPropertyCustomPropertyLegal()
{
var property = ParseDeclaration("transition-property : opacity, --My-Angle");
Assert.IsTrue(property.HasValue);
Assert.AreEqual("opacity, --My-Angle", property.Value);
}

[Test]
public void CssTransitionWithCustomPropertyLegal()
{
var property = ParseDeclaration("transition : --angle 1s");
Assert.IsTrue(property.HasValue);
Assert.AreEqual("--angle 1s", property.Value);
}

[Test]
public void CssTransitionPropertySlidingVerticallyIllegal()
{
Expand Down
68 changes: 68 additions & 0 deletions src/AngleSharp.Css.Tests/Extensions/Acid3Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#nullable disable
namespace AngleSharp.Css.Tests.Extensions
{
using AngleSharp.Css.Dom;
using AngleSharp.Css.Parser;
using AngleSharp.Dom;
using AngleSharp.Html.Parser;
using NUnit.Framework;

/// <summary>
/// Behavior the Acid3 test (acid3.acidtests.org) relies on.
/// </summary>
[TestFixture]
public class Acid3Tests
{
[TestCase("color: red ! important", "rgba(255, 0, 0, 1)")]
[TestCase("color: red !important", "rgba(255, 0, 0, 1)")]
[TestCase("color: red!IMPORTANT ", "rgba(255, 0, 0, 1)")]
[TestCase("border: 1px solid ! important", "1px solid")]
public void ImportantMayHaveWhitespaceAfterTheBang(System.String declaration, System.String expected)
{
var parser = new CssParser();
var sheet = parser.ParseStyleSheet($"p {{ {declaration} }}");
var style = ((ICssStyleRule)sheet.Rules[0]).Style;
var name = declaration.Substring(0, declaration.IndexOf(':'));

Assert.AreEqual("important", style.GetPropertyPriority(name));
Assert.AreEqual(expected, style.GetPropertyValue(name));
}

[Test]
public void ImportantNeedsTheBang()
{
var parser = new CssParser();
var sheet = parser.ParseStyleSheet("p { color: red important }");
var style = ((ICssStyleRule)sheet.Rules[0]).Style;

Assert.AreEqual(System.String.Empty, style.GetPropertyPriority("color"));
}

[TestCase("all and (min-color: 0)", true)]
[TestCase("(color)", true)]
[TestCase("(min-color: 1)", true)]
[TestCase("(max-color: 0)", false)]
[TestCase("(monochrome)", false)]
[TestCase("(max-monochrome: 0)", true)]
[TestCase("(min-monochrome: 1)", false)]
[TestCase("(max-color: 0) and (max-monochrome: 0)", false)]
[TestCase("(min-color: 1), (min-monochrome: 1)", true)]
[TestCase("not all and (min-color: 1), not all and (min-monochrome: 1)", true)]
[TestCase("not all and (bogus)", false)]
[TestCase("(bogus), all", true)]
public void MediaQueriesOfAColorScreen(System.String query, System.Boolean expected)
{
var window = CreateWindow(new DefaultRenderDevice { ColorBits = 32, MonochromeBits = 0, ViewPortWidth = 1000, ViewPortHeight = 800 });
Assert.AreEqual(expected, window.MatchMedia(query).IsMatched, query);
}

private static IWindow CreateWindow(IRenderDevice device)
{
var config = Configuration.Default.WithCss().WithRenderDevice(device);
var context = BrowsingContext.New(config);
var parser = context.GetService<IHtmlParser>();
var document = parser.ParseDocument("<!doctype html><title>Example</title>");
return document.DefaultView;
}
}
}
Loading