@angular/material
Version:
Angular Material
1 lines • 2.89 kB
Source Map (JSON)
{"version":3,"file":"control.mjs","sources":["../../../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/src/material/form-field/testing/control/form-field-control-harness.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 {ComponentHarness} from '@angular/cdk/testing';\n\n/**\n * Base class for custom form-field control harnesses. Harnesses for\n * custom controls with form-fields need to implement this interface.\n */\nexport abstract class MatFormFieldControlHarness extends ComponentHarness {}\n\n/**\n * Shared behavior for `MatFormFieldControlHarness` implementations\n */\nexport abstract class MatFormFieldControlHarnessBase extends MatFormFieldControlHarness {\n /**\n * Gets the label for the control, if it exists. This might be provided by a label element or by\n * the `aria-label` attribute.\n */\n async getLabel(): Promise<string | null> {\n const documentRootLocator = this.documentRootLocatorFactory();\n const labelId = await (await this.host()).getAttribute('aria-labelledby');\n const labelText = await (await this.host()).getAttribute('aria-label');\n const hostId = await (await this.host()).getAttribute('id');\n\n if (labelId) {\n // First, try to find the label by following [aria-labelledby]\n const labelEl = await documentRootLocator.locatorForOptional(`[id=\"${labelId}\"]`)();\n return labelEl ? labelEl.text() : null;\n } else if (labelText) {\n // If that doesn't work, return [aria-label] if it exists\n return labelText;\n } else if (hostId) {\n // Finally, search the DOM for a label that points to the host element\n const labelEl = await documentRootLocator.locatorForOptional(`[for=\"${hostId}\"]`)();\n return labelEl ? labelEl.text() : null;\n }\n return null;\n }\n}\n"],"names":[],"mappings":";;AAUA;;;AAGG;AACG,MAAgB,0BAA2B,SAAQ,gBAAgB,CAAA;AAAG;AAE5E;;AAEG;AACG,MAAgB,8BAA+B,SAAQ,0BAA0B,CAAA;AACrF;;;AAGG;AACH,IAAA,MAAM,QAAQ,GAAA;AACZ,QAAA,MAAM,mBAAmB,GAAG,IAAI,CAAC,0BAA0B,EAAE;AAC7D,QAAA,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,YAAY,CAAC,iBAAiB,CAAC;AACzE,QAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,YAAY,CAAC,YAAY,CAAC;AACtE,QAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC;QAE3D,IAAI,OAAO,EAAE;;AAEX,YAAA,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,kBAAkB,CAAC,CAAA,KAAA,EAAQ,OAAO,CAAA,EAAA,CAAI,CAAC,EAAE;AACnF,YAAA,OAAO,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,IAAI;;aACjC,IAAI,SAAS,EAAE;;AAEpB,YAAA,OAAO,SAAS;;aACX,IAAI,MAAM,EAAE;;AAEjB,YAAA,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,kBAAkB,CAAC,CAAA,MAAA,EAAS,MAAM,CAAA,EAAA,CAAI,CAAC,EAAE;AACnF,YAAA,OAAO,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,IAAI;;AAExC,QAAA,OAAO,IAAI;;AAEd;;;;"}