Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-invalid-link-text error with handlebars aria-label #2798

Closed
Yelinz opened this issue Feb 6, 2023 · 0 comments · Fixed by #2843
Closed

no-invalid-link-text error with handlebars aria-label #2798

Yelinz opened this issue Feb 6, 2023 · 0 comments · Fixed by #2843
Labels

Comments

@Yelinz
Copy link

Yelinz commented Feb 6, 2023

Example

<a aria-label={{this.text}}/>

When using an aria-label with the value not set by a plain string it throws this error

TypeError: Cannot read properties of undefined (reading 'replace')

Which stems from this line

const nbspRemoved = text.replace(/&nbsp;/g, ' ');

The problem is probably trying to use .chars

let ariaLabel = getTrimmedText(ariaLabelAttr.value.chars);

Log of ariaLabelAttr with <a aria-label={{t "translation"}}>

{
  type: 'AttrNode',
  name: 'aria-label',
  value: {
    type: 'MustacheStatement',
    path: PathExpressionImplV1 {
      original: 't',
      loc: [SourceSpan],
      type: 'PathExpression',
      this: false,
      data: false,
      _head: undefined,
      parts: [Array]
    },
    params: [ [Object] ],
    hash: { type: 'Hash', pairs: [], loc: [SourceSpan] },
    escaped: true,
    trusting: false,
    loc: SourceSpan { data: [HbsSpan], isInvisible: false },
    strip: { open: false, close: false }
  },
  loc: SourceSpan {
    data: HbsSpan {
      source: [Source],
      hbsPositions: [Object],
      kind: 'HbsPosition',
      _charPosSpan: null,
      _providedHbsLoc: null
    },
    isInvisible: false
  },
  isValueless: false,
  quoteType: null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants