Skip to content

DEV: Add backward compatibility for tag object arrays - #47

Merged
tgxworld merged 1 commit into
mainfrom
fix-tag-object-compatibility
Jan 19, 2026
Merged

DEV: Add backward compatibility for tag object arrays#47
tgxworld merged 1 commit into
mainfrom
fix-tag-object-compatibility

Conversation

@tgxworld

Copy link
Copy Markdown
Contributor

What is the problem?

Discourse core PR #36678 changes renderTag to pass tag objects
instead of strings to custom tag renderers. This breaks the
iconTagRenderer function which expects the tag parameter to be
a string and calls escapeExpression(tag) directly.

What is the solution?

Extract the tag name at the start of iconTagRenderer using
typeof tag === "string" ? tag : tag.name before processing.
Also rename the local tagName variable to htmlTagName to avoid
confusion with the extracted tag name. This ensures backward
compatibility with both the old string format and the new object format.

@tgxworld
tgxworld force-pushed the fix-tag-object-compatibility branch 4 times, most recently from ba35ede to 627dade Compare January 16, 2026 05:55
What is the problem?

Discourse core PR #36678 changes `renderTag` to pass tag objects
instead of strings to custom tag renderers. This breaks the
`iconTagRenderer` function which expects the `tag` parameter to be
a string and calls `escapeExpression(tag)` directly.

What is the solution?

Extract the tag name at the start of `iconTagRenderer` using
`typeof tag === "string" ? tag : tag.name` before processing.
Also rename the local `tagName` variable to `htmlTagName` to avoid
confusion with the extracted tag name. This ensures backward
compatibility with both the old string format and the new object format.
@tgxworld
tgxworld force-pushed the fix-tag-object-compatibility branch from 627dade to 69a4b41 Compare January 19, 2026 05:33
@tgxworld
tgxworld merged commit 75d7f1d into main Jan 19, 2026
5 checks passed
@tgxworld
tgxworld deleted the fix-tag-object-compatibility branch January 19, 2026 05:45
gormus added a commit to gormus/discourse-tag-icons that referenced this pull request Jan 25, 2026
commit 75d7f1d
Author: Alan Guo Xiang Tan <gxtan1990@gmail.com>
Date:   Mon Jan 19 13:45:11 2026 +0800

    DEV: Add backward compatibility for tag object arrays (discourse#47)

    What is the problem?

    Discourse core PR #36678 changes `renderTag` to pass tag objects
    instead of strings to custom tag renderers. This breaks the
    `iconTagRenderer` function which expects the `tag` parameter to be
    a string and calls `escapeExpression(tag)` directly.

    What is the solution?

    Extract the tag name at the start of `iconTagRenderer` using
    `typeof tag === "string" ? tag : tag.name` before processing.
    Also rename the local `tagName` variable to `htmlTagName` to avoid
    confusion with the extracted tag name. This ensures backward
    compatibility with both the old string format and the new object format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants