0.2.1: height={nil} works, and the README stops arguing against Leaflet - #2
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two things surfaced by using 0.2.0 in a real application.
height={nil}was documented but illegal — and then still brokenattr :height, :stringrejected thenilits own doc recommended. Phoenix emitsattribute "height" ... must be a :string, got: nil— a compile warning, so an error in any project building with--warnings-as-errors. Now:any, like:classalways was.Fixing the type was not enough.
style={@height && …}rendersstyle=""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 byclass="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 ownstylewins.Three tests:
height={nil}emits nostyle, a caller'sstyleoverrides, 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,heightbeats your class, stroke opacity goes throughrgba().The two remaining mentions in the JavaScript stay; one of them explains why
resolveRetinaexists at all.131 Elixir tests, 48 Node tests.
🤖 Generated with Claude Code