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

Define toStringTag another way #4855

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Define toStringTag another way
  • Loading branch information
matthewp committed Sep 23, 2022
commit d82b4383df9275d9986ab37b040dec570d885582
11 changes: 7 additions & 4 deletions packages/astro/src/runtime/server/escape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { escape } from 'html-escaper';
// Leverage the battle-tested `html-escaper` npm package.
export const escapeHTML = escape;

export class HTMLBytes extends Uint8Array {
// @ts-ignore
get [Symbol.toStringTag]() {
export class HTMLBytes extends Uint8Array {}

// TypeScript won't let us define this in the class body so have to do it
// this way. Boo.
Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, {
get() {
return 'HTMLBytes';
}
}
});

/**
* A "blessed" extension of String that tells Astro that the string
Expand Down