Skip to content

v0.8.0

Choose a tag to compare

@dhamidi dhamidi released this 17 Mar 11:36
· 161 commits to main since this release

What's new in v0.8.0

New package: htmlctest

The htmlctest package provides a fluent testing API for htmlc components.
It replaces the previous free-function API with a composable, discoverable design:

  • Harness — entry point for building a test environment. Use NewHarness or Build to create one, With to lazily register components, and Page / Fragment to render them.
  • Result — holds a rendered HTML output. Parses lazily with Document(), supports tree-diffing assertions via AssertHTML, and returns a Selection via Find(Query).
  • Query — immutable value type for describing element searches. Combine with WithClass, WithAttr, and Descendant to narrow selectors.
  • Selection — fluent assertion chain over matched elements. Methods include AssertExists, AssertNotExists, Count, Text, Attr, Nodes, and Check (with a SelectionChecker interface for custom assertions).

Migration stubs in stubs.go preserve source compatibility and emit t.Fatalf messages with replacement instructions for callers of the old API.

Improved struct property handling

StructProps now uses a two-pass key enumeration algorithm: direct (non-anonymous) fields are collected first, followed by anonymous embedded fields. The first-rune-lowercase alias is a lookup-only affordance and is intentionally excluded from Keys() to avoid double-exposure. Nil pointer chains are handled safely — newStructProps dereferences any chain of pointers and returns false on nil.

Dependency promotion

golang.org/x/net/html is promoted from an indirect to a direct dependency, used by htmlctest for HTML parsing.