@angular/material
Version:
Angular Material
1 lines • 3.14 kB
Source Map (JSON)
{"version":3,"file":"form-field-testing-control.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/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":["MatFormFieldControlHarness","ComponentHarness","MatFormFieldControlHarnessBase","getLabel","documentRootLocator","documentRootLocatorFactory","labelId","host","getAttribute","labelText","hostId","labelEl","locatorForOptional","text"],"mappings":";;AAcM,MAAgBA,0BAA2B,SAAQC,gBAAgB,CAAA;AAKnE,MAAgBC,8BAA+B,SAAQF,0BAA0B,CAAA;EAKrF,MAAMG,QAAQA,GAAA;AACZ,IAAA,MAAMC,mBAAmB,GAAG,IAAI,CAACC,0BAA0B,EAAE;AAC7D,IAAA,MAAMC,OAAO,GAAG,MAAM,CAAC,MAAM,IAAI,CAACC,IAAI,EAAE,EAAEC,YAAY,CAAC,iBAAiB,CAAC;AACzE,IAAA,MAAMC,SAAS,GAAG,MAAM,CAAC,MAAM,IAAI,CAACF,IAAI,EAAE,EAAEC,YAAY,CAAC,YAAY,CAAC;AACtE,IAAA,MAAME,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,CAACH,IAAI,EAAE,EAAEC,YAAY,CAAC,IAAI,CAAC;AAE3D,IAAA,IAAIF,OAAO,EAAE;AAEX,MAAA,MAAMK,OAAO,GAAG,MAAMP,mBAAmB,CAACQ,kBAAkB,CAAC,CAAA,KAAA,EAAQN,OAAO,CAAA,EAAA,CAAI,CAAC,EAAE;MACnF,OAAOK,OAAO,GAAGA,OAAO,CAACE,IAAI,EAAE,GAAG,IAAI;KACxC,MAAO,IAAIJ,SAAS,EAAE;AAEpB,MAAA,OAAOA,SAAS;KAClB,MAAO,IAAIC,MAAM,EAAE;AAEjB,MAAA,MAAMC,OAAO,GAAG,MAAMP,mBAAmB,CAACQ,kBAAkB,CAAC,CAAA,MAAA,EAASF,MAAM,CAAA,EAAA,CAAI,CAAC,EAAE;MACnF,OAAOC,OAAO,GAAGA,OAAO,CAACE,IAAI,EAAE,GAAG,IAAI;AACxC;AACA,IAAA,OAAO,IAAI;AACb;AACD;;;;"}