Skip to content

Switch to a supported TextEncoder/TextDecoder impl #243

@ChALkeR

Description

@ChALkeR

You are using jsdom 25, current is 28, and it comes with TextEncoder/TextDecoder since >=27.4.0
The implementation it uses is @exodus/bytes/encoding.js

https://www.npmjs.com/package/@sinonjs/text-encoding (and the deprecated package it forked) fails WPT and other tests, while that impl passes them.

It also seems impossible to file issues to https://github.com/sinonjs/text-encoding, and this repo seems to be the only intended consumer?

I suggest you deprecate it and replace with @exodus/bytes/encoding.js (or @exodus/bytes/encoding-lite.js if you don't need legacy multi-byte encodings support in TextDecoder).


Also you seem to only be using TextEncoder, and doing that incorrectly.
TextEncoder (including in your own package which is a fork of a deprecated repo) supports only UTF-8 encoding, while you are passing a label to it.

return new GlobalTextEncoder(encoding || "utf-8").encode(body).buffer;

You don't even the whole polyfill here, just import { utf8fromString } from '@exodus/bytes/utf8.js', then e.g. utf8fromString(string).slice(0).buffer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions