html_impl.d.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @license
  3. * SPDX-License-Identifier: Apache-2.0
  4. */
  5. /// <reference types="trusted-types" />
  6. import '../environment/dev';
  7. /**
  8. * String that is safe to use in HTML contexts in DOM APIs and HTML
  9. documents.
  10. */
  11. export declare type SafeHtml = TrustedHTML;
  12. /**
  13. * Also exports the constructor so that instanceof checks work.
  14. */
  15. export declare const SafeHtml: typeof TrustedHTML;
  16. /**
  17. * Builds a new `SafeHtml` from the given string, without enforcing safety
  18. * guarantees. It may cause side effects by creating a Trusted Types policy.
  19. * This shouldn't be exposed to application developers, and must only be used as
  20. * a step towards safe builders or safe constants.
  21. */
  22. export declare function createHtml(html: string): SafeHtml;
  23. /**
  24. * An empty `SafeHtml` constant.
  25. * Unlike the function above, using this will not create a policy.
  26. */
  27. export declare const EMPTY_HTML: SafeHtml;
  28. /**
  29. * Checks if the given value is a `SafeHtml` instance.
  30. */
  31. export declare function isHtml(value: unknown): value is SafeHtml;
  32. /**
  33. * Returns the value of the passed `SafeHtml` object while ensuring it
  34. * has the correct type.
  35. *
  36. * Returns a native `TrustedHTML` or a string if Trusted Types are disabled.
  37. */
  38. export declare function unwrapHtml(value: SafeHtml): TrustedHTML | string;