nativescript-community / nativescript-community/ui-label

Ampersand (&) results in incorrect rendering of HTML

Open
#18 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
20
Forks
9
Avg merge
1d 11h
Merged PRs (30d)
3

Description

If the demo apps cannot help and there is no issue for your problem, tell us about it

Demo via NS Preview: https://stackblitz.com/edit/nativescript-stackblitz-templates-ipbbwj?file=app%2Fcomponents%2FHome.vue

Which platform(s) does your issue occur on?
  • Tested on Android 12 to replicate the ampersand issue.
  • Could not test on iOS 16.5 as I was getting ReferenceError: UILabelLinkHandlerTapDelegate is not defined (not sure if it's an NS Preview issue). However when testing in the application I'm working on I saw the same behaviour.
Please, tell us how to recreate the issue in as much detail as possible.

The issue is that HTML is not rendered properly when including ampersands in the text. Example:

<HtmlLabel :html="'<h1>T&Cs</h1>'" /> <!-- this is rendered as HTML (i.e. '<h1>T&Cs</h1>') -->
<HtmlLabel :html="'<h1>T and Cs</h1>'" /> <!-- works as expected -->

I've tried using HTML Entities instead of the & symbol on its own but it resulted in the same thing.

<HtmlLabel :html="'<h1>T&amp;Cs</h1>'" /> <!-- this is rendered as HTML (i.e. '<h1>T&Cs</h1>') -->

I've included other examples in the NS Preview link above.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the examples in app/components/Home.vue from the linked NS Preview, using the Android 12 context described in the issue. Compare HtmlLabel output for a literal ampersand, an HTML entity, and the working “and” text. Done means ampersands and entities render correctly in the HTML label without changing the expected heading markup.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.