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

Add htmlSafe and isHTMLSafe exported methods. These will error when called, telling the user to import from @ember/template. #367

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Changes from all commits
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
20 changes: 20 additions & 0 deletions addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@module @ember/string
*/
import Cache from './cache';
import { deprecate } from '@ember/debug';

// STATE within a module is frowned upon, this exists
// to support Ember.STRINGS but shield ember internals from this legacy global
Expand Down Expand Up @@ -250,3 +251,22 @@ export function underscore(str: string): string {
export function capitalize(str: string): string {
return CAPITALIZE_CACHE.get(str);
}

/*
The following are implemented here to give users adding `@ember/string` to
their projects a useful error message. The `ember-source` implementation of
`@ember/string` is clobbered by adding this addon, and so the deprecation of
the import path is not triggered. This error message is intended to help
users discover what they need to change.
*/
export function htmlSafe(str: string): void {
throw new Error(
'htmlSafe is not implemented in the `@ember/string` package. Please import from `@ember/template` instead.'
);
}

export function isHTMLSafe(str: any | null | undefined): void {
throw new Error(
'isHTMLSafe is not implemented in the `@ember/string` package. Please import from `@ember/template` instead.'
);
}