Skip to content

bug(core): push() skips sanitizeText when text is undefined #248

Closed as not planned

Description

@vamgan

Summary

In ctx.push(), sanitizeText is only called when text is truthy. When text is undefined (or an empty string), the sanitizer is bypassed and the fallback '' is stored directly. This is inconsistent with DOM-based focus paths where the sanitizer always runs on the extracted text.

Root cause

packages/core/src/context.ts:

const sanitizedText = this.sanitizeTextFn && text
  ? this.sanitizeTextFn(text)
  : (text ?? '');

If text is undefined and a sanitizeTextFn exists, the sanitizer is never invoked.

Expected behavior

The sanitizer should be called on the resolved value:

const sanitizedText = this.sanitizeTextFn
  ? this.sanitizeTextFn(text ?? '')
  : (text ?? '');

Impact

Low in most cases (empty string is safe), but it creates an inconsistent contract for users who configure sanitizeText expecting it to intercept every stored text value, including empty/undefined ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreCore package and cross-package runtime behaviorbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions