UNPKG

@angular/cdk

Version:

Angular Material Component Development Kit

1 lines 6.41 kB
{"version":3,"file":"private.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/private/visually-hidden/visually-hidden.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/private/trusted-types.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/private/inner-html.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';\n\n/**\n * Component used to load the .cdk-visually-hidden styles.\n * @docs-private\n */\n@Component({\n styleUrl: 'visually-hidden.css',\n exportAs: 'cdkVisuallyHidden',\n encapsulation: ViewEncapsulation.None,\n template: '',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class _VisuallyHiddenLoader {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// A module to facilitate use of a Trusted Types policy internally within\n// Angular Material. It lazily constructs the Trusted Types policy, providing\n// helper utilities for promoting strings to Trusted Types. When Trusted Types\n// are not available, strings are used as a fallback.\n// All use of this module is security-sensitive and should go through security review.\n\nexport interface TrustedHTML {\n __brand__: 'TrustedHTML';\n}\n\ninterface TrustedTypePolicyFactory {\n createPolicy(\n policyName: string,\n policyOptions: {\n createHTML?: (input: string) => string;\n },\n ): TrustedTypePolicy;\n}\n\ninterface TrustedTypePolicy {\n createHTML(input: string): TrustedHTML;\n}\n\n/**\n * The Trusted Types policy, or null if Trusted Types are not\n * enabled/supported, or undefined if the policy has not been created yet.\n */\nlet policy: TrustedTypePolicy | null | undefined;\n\n/**\n * Returns the Trusted Types policy, or null if Trusted Types are not\n * enabled/supported. The first call to this function will create the policy.\n */\nfunction getPolicy(): TrustedTypePolicy | null {\n if (policy === undefined) {\n policy = null;\n if (typeof window !== 'undefined') {\n const ttWindow = window as unknown as {trustedTypes?: TrustedTypePolicyFactory};\n if (ttWindow.trustedTypes !== undefined) {\n policy = ttWindow.trustedTypes.createPolicy('angular#components', {\n createHTML: (s: string) => s,\n });\n }\n }\n }\n return policy;\n}\n\n/**\n * Unsafely promote a string to a TrustedHTML, falling back to strings when\n * Trusted Types are not available.\n *\n * Important!!! This is a security-sensitive function; any use of this function\n * must go through security review. In particular, it must be assured that the\n * provided string will never cause an XSS vulnerability if used in a context\n * that will be interpreted as HTML by a browser, e.g. when assigning to\n * element.innerHTML.\n */\nexport function trustedHTMLFromString(html: string): TrustedHTML {\n return getPolicy()?.createHTML(html) || (html as unknown as TrustedHTML);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SecurityContext} from '@angular/core';\nimport {DomSanitizer, SafeHtml} from '@angular/platform-browser';\nimport {trustedHTMLFromString} from './trusted-types';\n\n// !!!Note!!! this file isn't synced into g3, but is replaced with a version that uses\n// internal-specific APIs. The internal version may have to be updated if the signature of\n// the function changes.\n\n/** Sanitizes and sets the `innerHTML` of an element. */\nexport function _setInnerHtml(element: HTMLElement, html: SafeHtml, sanitizer: DomSanitizer): void {\n const cleanHtml = sanitizer.sanitize(SecurityContext.HTML, html);\n\n if (cleanHtml === null && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw new Error(`Could not sanitize HTML: ${html}`);\n }\n\n element.innerHTML = trustedHTMLFromString(cleanHtml || '') as unknown as string;\n}\n"],"names":["_VisuallyHiddenLoader","deps","target","i0","ɵɵFactoryTarget","Component","ɵcmp","ɵɵngDeclareComponent","minVersion","version","type","isInline","styles","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","decorators","policy","getPolicy","undefined","window","ttWindow","trustedTypes","createPolicy","createHTML","s","trustedHTMLFromString","html","_setInnerHtml","element","sanitizer","cleanHtml","sanitize","SecurityContext","HTML","ngDevMode","Error","innerHTML"],"mappings":";;;;MAqBaA,qBAAqB,CAAA;;;;;UAArBA,qBAAqB;AAAAC,IAAAA,IAAA,EAAA,EAAA;AAAAC,IAAAA,MAAA,EAAAC,EAAA,CAAAC,eAAA,CAAAC;AAAA,GAAA,CAAA;AAArB,EAAA,OAAAC,IAAA,GAAAH,EAAA,CAAAI,oBAAA,CAAA;AAAAC,IAAAA,UAAA,EAAA,QAAA;AAAAC,IAAAA,OAAA,EAAA,QAAA;AAAAC,IAAAA,IAAA,EAAAV,qBAAqB;;;;;cAHtB,EAAE;AAAAW,IAAAA,QAAA,EAAA,IAAA;IAAAC,MAAA,EAAA,CAAA,oQAAA,CAAA;AAAAC,IAAAA,eAAA,EAAAV,EAAA,CAAAW,uBAAA,CAAAC,MAAA;AAAAC,IAAAA,aAAA,EAAAb,EAAA,CAAAc,iBAAA,CAAAC;AAAA,GAAA,CAAA;;;;;;QAGDlB,qBAAqB;AAAAmB,EAAAA,UAAA,EAAA,CAAA;UAPjCd,SAAS;;gBAEE,mBAAmB;MAAAW,aAAA,EACdC,iBAAiB,CAACC,IAAI;gBAC3B,EAAE;MAAAL,eAAA,EACKC,uBAAuB,CAACC,MAAM;MAAAH,MAAA,EAAA,CAAA,oQAAA;KAAA;;;;ACgBjD,IAAIQ,MAA4C;AAMhD,SAASC,SAASA,GAAA;EAChB,IAAID,MAAM,KAAKE,SAAS,EAAE;AACxBF,IAAAA,MAAM,GAAG,IAAI;AACb,IAAA,IAAI,OAAOG,MAAM,KAAK,WAAW,EAAE;MACjC,MAAMC,QAAQ,GAAGD,MAA8D;AAC/E,MAAA,IAAIC,QAAQ,CAACC,YAAY,KAAKH,SAAS,EAAE;QACvCF,MAAM,GAAGI,QAAQ,CAACC,YAAY,CAACC,YAAY,CAAC,oBAAoB,EAAE;UAChEC,UAAU,EAAGC,CAAS,IAAKA;AAC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