link.d.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @license
  3. * SPDX-License-Identifier: Apache-2.0
  4. */
  5. import { Url } from '../../builders/url_sanitizer';
  6. import { TrustedResourceUrl } from '../../internals/resource_url_impl';
  7. declare const SAFE_URL_REL_VALUES: readonly ["alternate", "author", "bookmark", "canonical", "cite", "help", "icon", "license", "next", "prefetch", "dns-prefetch", "prerender", "preconnect", "preload", "prev", "search", "subresource"];
  8. /**
  9. * Values of the "rel" attribute when "href" should accept `SafeUrl` instead of
  10. * `TrustedResourceUrl`.
  11. */
  12. export declare type SafeUrlRelTypes = typeof SAFE_URL_REL_VALUES[number];
  13. /**
  14. * Values of the "rel" attribute when "href" should accept a
  15. * `TrustedResourceUrl`. Note that this list is not exhaustive and is here just
  16. * for better documentation, any unknown "rel" values will also require passing
  17. * a `TrustedResourceUrl` "href".
  18. */
  19. export declare type TrustedResourecUrlRelTypes = 'stylesheet' | 'manifest';
  20. /**
  21. * Safely sets a link element's "href" property using a sensitive "rel" value.
  22. */
  23. export declare function setHrefAndRel(link: HTMLLinkElement, url: TrustedResourceUrl, rel: TrustedResourecUrlRelTypes): void;
  24. /**
  25. * Safely sets a link element's "href" property using a non-sensitive "rel"
  26. * value.
  27. */
  28. export declare function setHrefAndRel(link: HTMLLinkElement, url: Url, rel: SafeUrlRelTypes): void;
  29. /**
  30. * Safely sets a link element's "href" property using an arbitrary "rel"
  31. * value.
  32. */
  33. export declare function setHrefAndRel(link: HTMLLinkElement, url: TrustedResourceUrl, rel: string): void;
  34. export {};