Skip to content

Merge shorthand classes when the attribute map has no :class - #18

Merged
borkdude merged 1 commit into
borkdude:mainfrom
telekid:merge-shorthand-classes
Sep 14, 2026
Merged

borkdude merged 1 commit into
borkdude:mainfrom
telekid:merge-shorthand-classes

Conversation

@telekid

@telekid telekid commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

merge-attrs only merged the shorthand classes from a tag like :div.card when the attribute map ALSO carried a :class key — the outer if-let tested the map's class, not the shorthand's. So

[:div.card {:id "a"}]   =>  <div id="a"></div>

silently lost the class, while

[:div.card {:class "big"}]  =>  <div class="card big"></div>

worked.

The same expression also interpolated at macroexpansion time, so a :class bound to anything non-constant rendered the symbol's NAME:

(let [x "big"] [:div.card {:class x}])  =>  class="card x"

`merge-attrs` only merged the shorthand classes from a tag like
`:div.card` when the attribute map ALSO carried a `:class` key — the
outer `if-let` tested the map's class, not the shorthand's. So

    [:div.card {:id "a"}]   =>  <div id="a"></div>

silently lost the class, while

    [:div.card {:class "big"}]  =>  <div class="card big"></div>

worked.

The same expression also interpolated at macroexpansion time, so a
`:class` bound to anything non-constant rendered the symbol's NAME:

    (let [x "big"] [:div.card {:class x}])  =>  class="card x"
@telekid telekid mentioned this pull request Sep 14, 2026
@borkdude
borkdude merged commit e09aa49 into borkdude:main Sep 14, 2026
1 check passed
@telekid
telekid deleted the merge-shorthand-classes branch September 14, 2026 17:58
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.

2 participants