Skip to content

0.2.1: height={nil} works, and the README stops arguing against Leaflet - #2

Merged
nseaSeb merged 1 commit into
mainfrom
fix/height-attr-and-readme
Aug 6, 2026
Merged

0.2.1: height={nil} works, and the README stops arguing against Leaflet#2
nseaSeb merged 1 commit into
mainfrom
fix/height-attr-and-readme

Conversation

@nseaSeb

@nseaSeb nseaSeb commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Two things surfaced by using 0.2.0 in a real application.

height={nil} was documented but illegal — and then still broken

attr :height, :string rejected the nil its own doc recommended. Phoenix emits attribute "height" ... must be a :string, got: nil — a compile warning, so an error in any project building with --warnings-as-errors. Now :any, like :class always was.

Fixing the type was not enough. style={@height && …} renders style="" for a nil value instead of omitting the attribute, and an empty inline style still beats a class in the cascade — so a map sized by class="h-96" or by a flex parent could not be sized at all, which is exactly the case the escape hatch exists for. The style is now a dynamic attribute, genuinely absent when there is no height, and placed after {@rest} so a caller's own style wins.

Three tests: height={nil} emits no style, a caller's style overrides, and the existing height/class case still holds.

The README stopped resting on someone else's library

The opening section was titled "Why not just use Leaflet?" and made a third-party project the yardstick for this one — while answering a question a Phoenix developer does not actually ask. The question in front of them is "why not just write a hook?", and that has the better answer: the first afternoon is short; the ones after it are the reconciliation, the framing, updated(), the coordinate order and the attribution.

Leaflet's name moves to Coming from a Leaflet hook — a migration table rather than a benchmark, which serves the people most likely to arrive here. It names the three things that catch them: markers need a stable :id, height beats your class, stroke opacity goes through rgba().

The two remaining mentions in the JavaScript stay; one of them explains why resolveRetina exists at all.

131 Elixir tests, 48 Node tests.

🤖 Generated with Claude Code

Two things surfaced by using 0.2.0 in a real application.

`attr :height, :string` rejected the `nil` its own documentation recommended.
Phoenix emits `attribute "height" ... must be a :string, got: nil`, which is a
compile warning — and therefore an error in any project building with
--warnings-as-errors, including this one. It is `:any` now, for the same reason
`:class` always was.

Fixing the type was not enough. `style={@height && ...}` renders `style=""` for a
nil value rather than omitting the attribute, and an empty inline style still
beats a class in the cascade — so a map sized by `class="h-96"` or by a flex
parent could not be sized at all, which is precisely the case the escape hatch
exists for. The style is now a dynamic attribute that is genuinely absent when
there is no height, placed after {@rest} so that a `style` the caller passes
themselves wins (HEEx keeps the first of two identical attribute names).

Separately, the README's opening argument was titled "Why not just use Leaflet?"
and rested its case on a comparison with someone else's library. That made a
third-party project the yardstick for this one, and answered a question a Phoenix
developer does not actually ask. The question in front of them is "why not just
write a hook?" — and that has a better answer: the first afternoon is short, and
the ones after it are the reconciliation, the framing, updated(), the coordinate
order and the attribution. Work Rover has already done, with tests that assert it
by object identity.

Leaflet's name moves to a "Coming from a Leaflet hook" section, where it is a
migration table rather than a benchmark — help for the people most likely to
arrive here, and it names the three things that catch them: markers need a stable
:id, height beats your class, and stroke opacity goes through rgba(). The two
remaining mentions in the JavaScript stay; one of them explains why resolveRetina
exists at all.

131 Elixir tests, 48 Node tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nseaSeb
nseaSeb merged commit 701dd8f into main Aug 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant