mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
refactor(ext/web): Don't rely on NaN comparisons in TextEncoderStream
(#13151)
In the `transform` function to `TextEncoderStream`'s internal `TransformStream`, if `chunk` is the empty string and `this.#pendingHighSurrogate` is null, then `lastCodeUnit` will be NaN. As it turns out, this does not cause a bug because the comparison to check for lone surrogates turns out to be false for NaN, but to rely on it makes the code brittle.
This commit is contained in:
parent
19c8cd3a45
commit
22d140ffb1
1 changed files with 3 additions and 0 deletions
|
@ -292,6 +292,9 @@
|
|||
transform: (chunk, controller) => {
|
||||
try {
|
||||
chunk = webidl.converters.DOMString(chunk);
|
||||
if (chunk === "") {
|
||||
return PromiseResolve();
|
||||
}
|
||||
if (this.#pendingHighSurrogate !== null) {
|
||||
chunk = this.#pendingHighSurrogate + chunk;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue