@kato-lee/cdk 14.2.7 → 20.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +8 -8
- package/_adev_assets/cdk_drag_drop.json +7215 -0
- package/_adev_assets/cdk_testing.json +7605 -0
- package/_adev_assets/cdk_testing_protractor.json +1747 -0
- package/_adev_assets/cdk_testing_selenium_webdriver.json +1801 -0
- package/_adev_assets/cdk_testing_testbed.json +1903 -0
- package/_index.scss +8 -8
- package/a11y/_index.scss +60 -102
- package/a11y/index.d.ts +550 -1212
- package/a11y-module.d.d.ts +314 -0
- package/a11y-prebuilt.css +1 -1
- package/accordion/index.d.ts +92 -140
- package/activedescendant-key-manager.d.d.ts +39 -0
- package/bidi/index.d.ts +21 -80
- package/bidi-module.d.d.ts +57 -0
- package/clipboard/index.d.ts +101 -115
- package/coercion/index.d.ts +45 -67
- package/coercion/private/index.d.ts +9 -0
- package/collections/index.d.ts +99 -374
- package/data-source.d.d.ts +43 -0
- package/dialog/index.d.ts +412 -469
- package/drag-drop/index.d.ts +1410 -1614
- package/fesm2022/a11y-module.mjs +951 -0
- package/fesm2022/a11y-module.mjs.map +1 -0
- package/fesm2022/a11y.mjs +538 -0
- package/fesm2022/a11y.mjs.map +1 -0
- package/fesm2022/accordion.mjs +216 -0
- package/fesm2022/accordion.mjs.map +1 -0
- package/fesm2022/activedescendant-key-manager.mjs +16 -0
- package/fesm2022/activedescendant-key-manager.mjs.map +1 -0
- package/fesm2022/array.mjs +6 -0
- package/fesm2022/array.mjs.map +1 -0
- package/fesm2022/bidi.mjs +78 -0
- package/fesm2022/bidi.mjs.map +1 -0
- package/fesm2022/breakpoints-observer.mjs +179 -0
- package/fesm2022/breakpoints-observer.mjs.map +1 -0
- package/fesm2022/cdk.mjs +7 -0
- package/fesm2022/cdk.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/clipboard.mjs +210 -259
- package/fesm2022/clipboard.mjs.map +1 -0
- package/fesm2022/coercion/private.mjs +15 -0
- package/fesm2022/coercion/private.mjs.map +1 -0
- package/fesm2022/coercion.mjs +43 -0
- package/fesm2022/coercion.mjs.map +1 -0
- package/fesm2022/collections.mjs +8 -0
- package/fesm2022/collections.mjs.map +1 -0
- package/fesm2022/css-pixel-value.mjs +10 -0
- package/fesm2022/css-pixel-value.mjs.map +1 -0
- package/fesm2022/data-source.mjs +15 -0
- package/fesm2022/data-source.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/dialog.mjs +874 -787
- package/fesm2022/dialog.mjs.map +1 -0
- package/fesm2022/directionality.mjs +77 -0
- package/fesm2022/directionality.mjs.map +1 -0
- package/fesm2022/dispose-view-repeater-strategy.mjs +44 -0
- package/fesm2022/dispose-view-repeater-strategy.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/drag-drop.mjs +4477 -3808
- package/fesm2022/drag-drop.mjs.map +1 -0
- package/fesm2022/element.mjs +29 -0
- package/fesm2022/element.mjs.map +1 -0
- package/fesm2022/fake-event-detection.mjs +24 -0
- package/fesm2022/fake-event-detection.mjs.map +1 -0
- package/fesm2022/focus-key-manager.mjs +22 -0
- package/fesm2022/focus-key-manager.mjs.map +1 -0
- package/fesm2022/focus-monitor.mjs +622 -0
- package/fesm2022/focus-monitor.mjs.map +1 -0
- package/fesm2022/id-generator.mjs +37 -0
- package/fesm2022/id-generator.mjs.map +1 -0
- package/fesm2022/keycodes.mjs +15 -0
- package/fesm2022/keycodes.mjs.map +1 -0
- package/{fesm2015/keycodes.mjs → fesm2022/keycodes2.mjs} +122 -167
- package/fesm2022/keycodes2.mjs.map +1 -0
- package/fesm2022/layout.mjs +43 -0
- package/fesm2022/layout.mjs.map +1 -0
- package/fesm2022/list-key-manager.mjs +360 -0
- package/fesm2022/list-key-manager.mjs.map +1 -0
- package/fesm2022/listbox.mjs +928 -0
- package/fesm2022/listbox.mjs.map +1 -0
- package/fesm2022/menu.mjs +2001 -0
- package/fesm2022/menu.mjs.map +1 -0
- package/fesm2022/observers/private.mjs +124 -0
- package/fesm2022/observers/private.mjs.map +1 -0
- package/fesm2022/observers.mjs +210 -0
- package/fesm2022/observers.mjs.map +1 -0
- package/{fesm2020/overlay.mjs → fesm2022/overlay-module.mjs} +3062 -3145
- package/fesm2022/overlay-module.mjs.map +1 -0
- package/fesm2022/overlay.mjs +101 -0
- package/fesm2022/overlay.mjs.map +1 -0
- package/fesm2022/passive-listeners.mjs +31 -0
- package/fesm2022/passive-listeners.mjs.map +1 -0
- package/fesm2022/platform.mjs +73 -0
- package/fesm2022/platform.mjs.map +1 -0
- package/fesm2022/platform2.mjs +77 -0
- package/fesm2022/platform2.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/portal.mjs +614 -689
- package/fesm2022/portal.mjs.map +1 -0
- package/fesm2022/private.mjs +19 -0
- package/fesm2022/private.mjs.map +1 -0
- package/fesm2022/recycle-view-repeater-strategy.mjs +156 -0
- package/fesm2022/recycle-view-repeater-strategy.mjs.map +1 -0
- package/{fesm2015 → fesm2022}/scrolling.mjs +1472 -1558
- package/fesm2022/scrolling.mjs.map +1 -0
- package/fesm2022/scrolling2.mjs +99 -0
- package/fesm2022/scrolling2.mjs.map +1 -0
- package/fesm2022/selection-model.mjs +221 -0
- package/fesm2022/selection-model.mjs.map +1 -0
- package/fesm2022/shadow-dom.mjs +49 -0
- package/fesm2022/shadow-dom.mjs.map +1 -0
- package/fesm2022/stepper.mjs +632 -0
- package/fesm2022/stepper.mjs.map +1 -0
- package/fesm2022/style-loader.mjs +47 -0
- package/fesm2022/style-loader.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/table.mjs +2511 -2348
- package/fesm2022/table.mjs.map +1 -0
- package/fesm2022/test-environment.mjs +19 -0
- package/fesm2022/test-environment.mjs.map +1 -0
- package/fesm2022/testing/selenium-webdriver.mjs +353 -0
- package/fesm2022/testing/selenium-webdriver.mjs.map +1 -0
- package/fesm2022/testing/testbed.mjs +782 -0
- package/fesm2022/testing/testbed.mjs.map +1 -0
- package/fesm2022/testing.mjs +950 -0
- package/fesm2022/testing.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/text-field.mjs +432 -459
- package/fesm2022/text-field.mjs.map +1 -0
- package/fesm2022/tree-key-manager.mjs +360 -0
- package/fesm2022/tree-key-manager.mjs.map +1 -0
- package/fesm2022/tree.mjs +1800 -0
- package/fesm2022/tree.mjs.map +1 -0
- package/fesm2022/typeahead.mjs +88 -0
- package/fesm2022/typeahead.mjs.map +1 -0
- package/fesm2022/unique-selection-dispatcher.mjs +49 -0
- package/fesm2022/unique-selection-dispatcher.mjs.map +1 -0
- package/focus-key-manager.d.d.ts +39 -0
- package/focus-monitor.d.d.ts +208 -0
- package/harness-environment.d.d.ts +944 -0
- package/index.d.ts +6 -6
- package/keycodes/index.d.ts +129 -249
- package/layout/index.d.ts +89 -90
- package/list-key-manager.d.d.ts +170 -0
- package/listbox/index.d.ts +354 -419
- package/menu/index.d.ts +834 -1013
- package/number-property.d.d.ts +16 -0
- package/observers/index.d.ts +84 -109
- package/observers/private/index.d.ts +34 -0
- package/overlay/_index-deprecated.scss +13 -13
- package/overlay/_index.scss +193 -152
- package/overlay/index.d.ts +328 -1343
- package/overlay-module.d.d.ts +801 -0
- package/overlay-prebuilt.css +1 -1
- package/package.json +177 -232
- package/platform/index.d.ts +67 -106
- package/platform.d.d.ts +33 -0
- package/portal/index.d.ts +51 -328
- package/portal-directives.d.d.ts +211 -0
- package/private/index.d.ts +13 -0
- package/schematics/collection.json +18 -0
- package/schematics/index.d.ts +14 -0
- package/schematics/index.js +37 -0
- package/schematics/index.js.map +1 -0
- package/schematics/migration.json +15 -0
- package/schematics/ng-add/index.d.ts +17 -0
- package/schematics/ng-add/index.js +31 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.d.ts +11 -0
- package/schematics/ng-add/schema.js +10 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +16 -0
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template +53 -0
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +21 -0
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +25 -0
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template +45 -0
- package/schematics/ng-generate/drag-drop/index.d.ts +11 -0
- package/schematics/ng-generate/drag-drop/index.js +42 -0
- package/schematics/ng-generate/drag-drop/index.js.map +1 -0
- package/schematics/ng-generate/drag-drop/schema.d.ts +10 -0
- package/schematics/ng-generate/drag-drop/schema.js +10 -0
- package/schematics/ng-generate/drag-drop/schema.js.map +1 -0
- package/schematics/ng-generate/drag-drop/schema.json +100 -0
- package/schematics/ng-update/data/attribute-selectors.d.ts +15 -0
- package/schematics/ng-update/data/attribute-selectors.js +12 -0
- package/schematics/ng-update/data/attribute-selectors.js.map +1 -0
- package/schematics/ng-update/data/class-names.d.ts +15 -0
- package/schematics/ng-update/data/class-names.js +12 -0
- package/schematics/ng-update/data/class-names.js.map +1 -0
- package/schematics/ng-update/data/constructor-checks.d.ts +15 -0
- package/schematics/ng-update/data/constructor-checks.js +17 -0
- package/schematics/ng-update/data/constructor-checks.js.map +1 -0
- package/schematics/ng-update/data/css-selectors.d.ts +27 -0
- package/schematics/ng-update/data/css-selectors.js +12 -0
- package/schematics/ng-update/data/css-selectors.js.map +1 -0
- package/schematics/ng-update/data/css-tokens.d.ts +27 -0
- package/schematics/ng-update/data/css-tokens.js +12 -0
- package/schematics/ng-update/data/css-tokens.js.map +1 -0
- package/schematics/ng-update/data/element-selectors.d.ts +15 -0
- package/schematics/ng-update/data/element-selectors.js +12 -0
- package/schematics/ng-update/data/element-selectors.js.map +1 -0
- package/schematics/ng-update/data/index.d.ts +18 -0
- package/schematics/ng-update/data/index.js +35 -0
- package/schematics/ng-update/data/index.js.map +1 -0
- package/schematics/ng-update/data/input-names.d.ts +22 -0
- package/schematics/ng-update/data/input-names.js +12 -0
- package/schematics/ng-update/data/input-names.js.map +1 -0
- package/schematics/ng-update/data/method-call-checks.d.ts +17 -0
- package/schematics/ng-update/data/method-call-checks.js +12 -0
- package/schematics/ng-update/data/method-call-checks.js.map +1 -0
- package/schematics/ng-update/data/output-names.d.ts +22 -0
- package/schematics/ng-update/data/output-names.js +12 -0
- package/schematics/ng-update/data/output-names.js.map +1 -0
- package/schematics/ng-update/data/property-names.d.ts +20 -0
- package/schematics/ng-update/data/property-names.js +12 -0
- package/schematics/ng-update/data/property-names.js.map +1 -0
- package/schematics/ng-update/data/symbol-removal.d.ts +17 -0
- package/schematics/ng-update/data/symbol-removal.js +12 -0
- package/schematics/ng-update/data/symbol-removal.js.map +1 -0
- package/schematics/ng-update/devkit-file-system.d.ts +30 -0
- package/schematics/ng-update/devkit-file-system.js +83 -0
- package/schematics/ng-update/devkit-file-system.js.map +1 -0
- package/schematics/ng-update/devkit-migration-rule.d.ts +24 -0
- package/schematics/ng-update/devkit-migration-rule.js +142 -0
- package/schematics/ng-update/devkit-migration-rule.js.map +1 -0
- package/schematics/ng-update/devkit-migration.d.ts +35 -0
- package/schematics/ng-update/devkit-migration.js +20 -0
- package/schematics/ng-update/devkit-migration.js.map +1 -0
- package/schematics/ng-update/find-stylesheets.d.ts +16 -0
- package/schematics/ng-update/find-stylesheets.js +41 -0
- package/schematics/ng-update/find-stylesheets.js.map +1 -0
- package/schematics/ng-update/html-parsing/angular.d.ts +15 -0
- package/schematics/ng-update/html-parsing/angular.js +51 -0
- package/schematics/ng-update/html-parsing/angular.js.map +1 -0
- package/schematics/ng-update/html-parsing/elements.d.ts +24 -0
- package/schematics/ng-update/html-parsing/elements.js +63 -0
- package/schematics/ng-update/html-parsing/elements.js.map +1 -0
- package/schematics/ng-update/index.d.ts +10 -0
- package/schematics/ng-update/index.js +29 -0
- package/schematics/ng-update/index.js.map +1 -0
- package/schematics/ng-update/migrations/attribute-selectors.d.ts +26 -0
- package/schematics/ng-update/migrations/attribute-selectors.js +71 -0
- package/schematics/ng-update/migrations/attribute-selectors.js.map +1 -0
- package/schematics/ng-update/migrations/class-inheritance.d.ts +26 -0
- package/schematics/ng-update/migrations/class-inheritance.js +58 -0
- package/schematics/ng-update/migrations/class-inheritance.js.map +1 -0
- package/schematics/ng-update/migrations/class-names.d.ts +32 -0
- package/schematics/ng-update/migrations/class-names.js +91 -0
- package/schematics/ng-update/migrations/class-names.js.map +1 -0
- package/schematics/ng-update/migrations/constructor-signature.d.ts +29 -0
- package/schematics/ng-update/migrations/constructor-signature.js +139 -0
- package/schematics/ng-update/migrations/constructor-signature.js.map +1 -0
- package/schematics/ng-update/migrations/css-selectors.d.ts +26 -0
- package/schematics/ng-update/migrations/css-selectors.js +75 -0
- package/schematics/ng-update/migrations/css-selectors.js.map +1 -0
- package/schematics/ng-update/migrations/css-tokens.d.ts +26 -0
- package/schematics/ng-update/migrations/css-tokens.js +83 -0
- package/schematics/ng-update/migrations/css-tokens.js.map +1 -0
- package/schematics/ng-update/migrations/element-selectors.d.ts +26 -0
- package/schematics/ng-update/migrations/element-selectors.js +66 -0
- package/schematics/ng-update/migrations/element-selectors.js.map +1 -0
- package/schematics/ng-update/migrations/input-names.d.ts +26 -0
- package/schematics/ng-update/migrations/input-names.js +59 -0
- package/schematics/ng-update/migrations/input-names.js.map +1 -0
- package/schematics/ng-update/migrations/method-call-arguments.d.ts +22 -0
- package/schematics/ng-update/migrations/method-call-arguments.js +62 -0
- package/schematics/ng-update/migrations/method-call-arguments.js.map +1 -0
- package/schematics/ng-update/migrations/misc-template.d.ts +18 -0
- package/schematics/ng-update/migrations/misc-template.js +25 -0
- package/schematics/ng-update/migrations/misc-template.js.map +1 -0
- package/schematics/ng-update/migrations/output-names.d.ts +22 -0
- package/schematics/ng-update/migrations/output-names.js +46 -0
- package/schematics/ng-update/migrations/output-names.js.map +1 -0
- package/schematics/ng-update/migrations/property-names.d.ts +22 -0
- package/schematics/ng-update/migrations/property-names.js +60 -0
- package/schematics/ng-update/migrations/property-names.js.map +1 -0
- package/schematics/ng-update/migrations/symbol-removal.d.ts +18 -0
- package/schematics/ng-update/migrations/symbol-removal.js +47 -0
- package/schematics/ng-update/migrations/symbol-removal.js.map +1 -0
- package/schematics/ng-update/public-api.d.ts +19 -0
- package/schematics/ng-update/public-api.js +36 -0
- package/schematics/ng-update/public-api.js.map +1 -0
- package/schematics/ng-update/typescript/base-types.d.ts +10 -0
- package/schematics/ng-update/typescript/base-types.js +23 -0
- package/schematics/ng-update/typescript/base-types.js.map +1 -0
- package/schematics/ng-update/typescript/imports.d.ts +18 -0
- package/schematics/ng-update/typescript/imports.js +53 -0
- package/schematics/ng-update/typescript/imports.js.map +1 -0
- package/schematics/ng-update/typescript/literal.d.ts +18 -0
- package/schematics/ng-update/typescript/literal.js +32 -0
- package/schematics/ng-update/typescript/literal.js.map +1 -0
- package/schematics/ng-update/typescript/module-specifiers.d.ts +16 -0
- package/schematics/ng-update/typescript/module-specifiers.js +35 -0
- package/schematics/ng-update/typescript/module-specifiers.js.map +1 -0
- package/schematics/ng-update/upgrade-data.d.ts +35 -0
- package/schematics/ng-update/upgrade-data.js +40 -0
- package/schematics/ng-update/upgrade-data.js.map +1 -0
- package/schematics/package.json +3 -0
- package/schematics/paths.d.ts +11 -0
- package/schematics/paths.js +16 -0
- package/schematics/paths.js.map +1 -0
- package/schematics/update-tool/component-resource-collector.d.ts +44 -0
- package/schematics/update-tool/component-resource-collector.js +164 -0
- package/schematics/update-tool/component-resource-collector.js.map +1 -0
- package/schematics/update-tool/file-system.d.ts +72 -0
- package/schematics/update-tool/file-system.js +18 -0
- package/schematics/update-tool/file-system.js.map +1 -0
- package/schematics/update-tool/index.d.ts +74 -0
- package/schematics/update-tool/index.js +172 -0
- package/schematics/update-tool/index.js.map +1 -0
- package/schematics/update-tool/logger.d.ts +15 -0
- package/schematics/update-tool/logger.js +18 -0
- package/schematics/update-tool/logger.js.map +1 -0
- package/schematics/update-tool/migration.d.ts +87 -0
- package/schematics/update-tool/migration.js +70 -0
- package/schematics/update-tool/migration.js.map +1 -0
- package/schematics/update-tool/public-api.d.ts +16 -0
- package/schematics/update-tool/public-api.js +33 -0
- package/schematics/update-tool/public-api.js.map +1 -0
- package/schematics/update-tool/target-version.d.ts +16 -0
- package/schematics/update-tool/target-version.js +27 -0
- package/schematics/update-tool/target-version.js.map +1 -0
- package/schematics/update-tool/update-recorder.d.ts +13 -0
- package/schematics/update-tool/update-recorder.js +10 -0
- package/schematics/update-tool/update-recorder.js.map +1 -0
- package/schematics/update-tool/utils/decorators.d.ts +22 -0
- package/schematics/update-tool/utils/decorators.js +41 -0
- package/schematics/update-tool/utils/decorators.js.map +1 -0
- package/schematics/update-tool/utils/diagnostics.d.ts +11 -0
- package/schematics/update-tool/utils/diagnostics.js +18 -0
- package/schematics/update-tool/utils/diagnostics.js.map +1 -0
- package/schematics/update-tool/utils/functions.d.ts +14 -0
- package/schematics/update-tool/utils/functions.js +20 -0
- package/schematics/update-tool/utils/functions.js.map +1 -0
- package/schematics/update-tool/utils/imports.d.ts +17 -0
- package/schematics/update-tool/utils/imports.js +110 -0
- package/schematics/update-tool/utils/imports.js.map +1 -0
- package/schematics/update-tool/utils/line-mappings.d.ts +21 -0
- package/schematics/update-tool/utils/line-mappings.js +75 -0
- package/schematics/update-tool/utils/line-mappings.js.map +1 -0
- package/schematics/update-tool/utils/parse-tsconfig.d.ts +18 -0
- package/schematics/update-tool/utils/parse-tsconfig.js +45 -0
- package/schematics/update-tool/utils/parse-tsconfig.js.map +1 -0
- package/schematics/update-tool/utils/property-name.d.ts +18 -0
- package/schematics/update-tool/utils/property-name.js +27 -0
- package/schematics/update-tool/utils/property-name.js.map +1 -0
- package/schematics/update-tool/utils/virtual-host.d.ts +36 -0
- package/schematics/update-tool/utils/virtual-host.js +71 -0
- package/schematics/update-tool/utils/virtual-host.js.map +1 -0
- package/schematics/update-tool/version-changes.d.ts +32 -0
- package/schematics/update-tool/version-changes.js +38 -0
- package/schematics/update-tool/version-changes.js.map +1 -0
- package/schematics/utils/ast/ng-module-imports.d.ts +12 -0
- package/schematics/utils/ast/ng-module-imports.js +82 -0
- package/schematics/utils/ast/ng-module-imports.js.map +1 -0
- package/schematics/utils/ast.d.ts +25 -0
- package/schematics/utils/ast.js +79 -0
- package/schematics/utils/ast.js.map +1 -0
- package/schematics/utils/build-component.d.ts +20 -0
- package/schematics/utils/build-component.js +189 -0
- package/schematics/utils/build-component.js.map +1 -0
- package/schematics/utils/get-project.d.ts +13 -0
- package/schematics/utils/get-project.js +28 -0
- package/schematics/utils/get-project.js.map +1 -0
- package/schematics/utils/html-manipulation.d.ts +15 -0
- package/schematics/utils/html-manipulation.js +91 -0
- package/schematics/utils/html-manipulation.js.map +1 -0
- package/schematics/utils/index.d.ts +19 -0
- package/schematics/utils/index.js +36 -0
- package/schematics/utils/index.js.map +1 -0
- package/schematics/utils/parse5-element.d.ts +12 -0
- package/schematics/utils/parse5-element.js +30 -0
- package/schematics/utils/parse5-element.js.map +1 -0
- package/schematics/utils/project-index-file.d.ts +13 -0
- package/schematics/utils/project-index-file.js +43 -0
- package/schematics/utils/project-index-file.js.map +1 -0
- package/schematics/utils/project-main-file.d.ts +11 -0
- package/schematics/utils/project-main-file.js +25 -0
- package/schematics/utils/project-main-file.js.map +1 -0
- package/schematics/utils/project-style-file.d.ts +13 -0
- package/schematics/utils/project-style-file.js +42 -0
- package/schematics/utils/project-style-file.js.map +1 -0
- package/schematics/utils/project-targets.d.ts +15 -0
- package/schematics/utils/project-targets.js +46 -0
- package/schematics/utils/project-targets.js.map +1 -0
- package/schematics/utils/project-tsconfig-paths.d.ts +14 -0
- package/schematics/utils/project-tsconfig-paths.js +46 -0
- package/schematics/utils/project-tsconfig-paths.js.map +1 -0
- package/schematics/utils/schematic-options.d.ts +20 -0
- package/schematics/utils/schematic-options.js +89 -0
- package/schematics/utils/schematic-options.js.map +1 -0
- package/scrolling/index.d.ts +62 -849
- package/scrolling-module.d.d.ts +551 -0
- package/selection-model.d.d.ts +112 -0
- package/stepper/index.d.ts +236 -419
- package/style-loader.d.d.ts +21 -0
- package/table/index.d.ts +901 -1483
- package/testing/index.d.ts +98 -0
- package/testing/selenium-webdriver/index.d.ts +150 -0
- package/testing/testbed/index.d.ts +157 -0
- package/text-field/_index.scss +89 -89
- package/text-field/index.d.ts +154 -203
- package/text-field-prebuilt.css +1 -1
- package/tree/index.d.ts +720 -593
- package/tree-key-manager-strategy.d.d.ts +116 -0
- package/unique-selection-dispatcher.d.d.ts +33 -0
- package/view-repeater.d.d.ts +88 -0
- package/a11y/_index.import.scss +0 -2
- package/esm2020/a11y/a11y-module.mjs +0 -32
- package/esm2020/a11y/a11y_public_index.mjs +0 -5
- package/esm2020/a11y/aria-describer/aria-describer.mjs +0 -232
- package/esm2020/a11y/aria-describer/aria-reference.mjs +0 -44
- package/esm2020/a11y/fake-event-detection.mjs +0 -31
- package/esm2020/a11y/focus-monitor/focus-monitor.mjs +0 -451
- package/esm2020/a11y/focus-trap/configurable-focus-trap-config.mjs +0 -9
- package/esm2020/a11y/focus-trap/configurable-focus-trap-factory.mjs +0 -53
- package/esm2020/a11y/focus-trap/configurable-focus-trap.mjs +0 -51
- package/esm2020/a11y/focus-trap/event-listener-inert-strategy.mjs +0 -61
- package/esm2020/a11y/focus-trap/focus-trap-inert-strategy.mjs +0 -11
- package/esm2020/a11y/focus-trap/focus-trap-manager.mjs +0 -53
- package/esm2020/a11y/focus-trap/focus-trap.mjs +0 -402
- package/esm2020/a11y/high-contrast-mode/high-contrast-mode-detector.mjs +0 -109
- package/esm2020/a11y/index.mjs +0 -9
- package/esm2020/a11y/input-modality/input-modality-detector.mjs +0 -176
- package/esm2020/a11y/interactivity-checker/interactivity-checker.mjs +0 -238
- package/esm2020/a11y/key-manager/activedescendant-key-manager.mjs +0 -20
- package/esm2020/a11y/key-manager/focus-key-manager.mjs +0 -29
- package/esm2020/a11y/key-manager/list-key-manager.mjs +0 -321
- package/esm2020/a11y/live-announcer/live-announcer-tokens.mjs +0 -19
- package/esm2020/a11y/live-announcer/live-announcer.mjs +0 -178
- package/esm2020/a11y/public-api.mjs +0 -26
- package/esm2020/accordion/accordion-item.mjs +0 -167
- package/esm2020/accordion/accordion-module.mjs +0 -24
- package/esm2020/accordion/accordion.mjs +0 -70
- package/esm2020/accordion/accordion_public_index.mjs +0 -5
- package/esm2020/accordion/index.mjs +0 -9
- package/esm2020/accordion/public-api.mjs +0 -11
- package/esm2020/bidi/bidi-module.mjs +0 -23
- package/esm2020/bidi/bidi_public_index.mjs +0 -5
- package/esm2020/bidi/dir-document-token.mjs +0 -33
- package/esm2020/bidi/dir.mjs +0 -69
- package/esm2020/bidi/directionality.mjs +0 -52
- package/esm2020/bidi/index.mjs +0 -9
- package/esm2020/bidi/public-api.mjs +0 -12
- package/esm2020/clipboard/clipboard-module.mjs +0 -23
- package/esm2020/clipboard/clipboard.mjs +0 -53
- package/esm2020/clipboard/clipboard_public_index.mjs +0 -5
- package/esm2020/clipboard/copy-to-clipboard.mjs +0 -99
- package/esm2020/clipboard/index.mjs +0 -9
- package/esm2020/clipboard/pending-copy.mjs +0 -69
- package/esm2020/clipboard/public-api.mjs +0 -12
- package/esm2020/coercion/array.mjs +0 -11
- package/esm2020/coercion/boolean-property.mjs +0 -12
- package/esm2020/coercion/css-pixel-value.mjs +0 -15
- package/esm2020/coercion/element.mjs +0 -16
- package/esm2020/coercion/index.mjs +0 -9
- package/esm2020/coercion/number-property.mjs +0 -21
- package/esm2020/coercion/public-api.mjs +0 -14
- package/esm2020/coercion/string-array.mjs +0 -38
- package/esm2020/collections/array-data-source.mjs +0 -21
- package/esm2020/collections/collection-viewer.mjs +0 -9
- package/esm2020/collections/collections_public_index.mjs +0 -5
- package/esm2020/collections/data-source.mjs +0 -19
- package/esm2020/collections/dispose-view-repeater-strategy.mjs +0 -47
- package/esm2020/collections/index.mjs +0 -9
- package/esm2020/collections/public-api.mjs +0 -17
- package/esm2020/collections/recycle-view-repeater-strategy.mjs +0 -128
- package/esm2020/collections/selection-model.mjs +0 -216
- package/esm2020/collections/tree-adapter.mjs +0 -9
- package/esm2020/collections/unique-selection-dispatcher.mjs +0 -55
- package/esm2020/collections/view-repeater.mjs +0 -14
- package/esm2020/dialog/dialog-config.mjs +0 -63
- package/esm2020/dialog/dialog-container.mjs +0 -278
- package/esm2020/dialog/dialog-injectors.mjs +0 -26
- package/esm2020/dialog/dialog-module.mjs +0 -42
- package/esm2020/dialog/dialog-ref.mjs +0 -76
- package/esm2020/dialog/dialog.mjs +0 -301
- package/esm2020/dialog/dialog_public_index.mjs +0 -5
- package/esm2020/dialog/index.mjs +0 -9
- package/esm2020/dialog/public-api.mjs +0 -14
- package/esm2020/drag-drop/directives/assertions.mjs +0 -18
- package/esm2020/drag-drop/directives/config.mjs +0 -14
- package/esm2020/drag-drop/directives/drag-handle.mjs +0 -66
- package/esm2020/drag-drop/directives/drag-placeholder.mjs +0 -36
- package/esm2020/drag-drop/directives/drag-preview.mjs +0 -47
- package/esm2020/drag-drop/directives/drag.mjs +0 -487
- package/esm2020/drag-drop/directives/drop-list-group.mjs +0 -53
- package/esm2020/drag-drop/directives/drop-list.mjs +0 -345
- package/esm2020/drag-drop/dom/client-rect.mjs +0 -64
- package/esm2020/drag-drop/dom/clone-node.mjs +0 -65
- package/esm2020/drag-drop/dom/parent-position-tracker.mjs +0 -76
- package/esm2020/drag-drop/dom/styling.mjs +0 -69
- package/esm2020/drag-drop/dom/transition-duration.mjs +0 -36
- package/esm2020/drag-drop/drag-drop-module.mjs +0 -57
- package/esm2020/drag-drop/drag-drop-registry.mjs +0 -231
- package/esm2020/drag-drop/drag-drop.mjs +0 -57
- package/esm2020/drag-drop/drag-drop_public_index.mjs +0 -5
- package/esm2020/drag-drop/drag-events.mjs +0 -9
- package/esm2020/drag-drop/drag-parent.mjs +0 -16
- package/esm2020/drag-drop/drag-ref.mjs +0 -1146
- package/esm2020/drag-drop/drag-utils.mjs +0 -60
- package/esm2020/drag-drop/drop-list-ref.mjs +0 -577
- package/esm2020/drag-drop/index.mjs +0 -9
- package/esm2020/drag-drop/public-api.mjs +0 -23
- package/esm2020/drag-drop/sorting/drop-list-sort-strategy.mjs +0 -9
- package/esm2020/drag-drop/sorting/single-axis-sort-strategy.mjs +0 -341
- package/esm2020/index.mjs +0 -9
- package/esm2020/keycodes/index.mjs +0 -9
- package/esm2020/keycodes/keycodes.mjs +0 -127
- package/esm2020/keycodes/keycodes_public_index.mjs +0 -5
- package/esm2020/keycodes/modifiers.mjs +0 -18
- package/esm2020/keycodes/public-api.mjs +0 -10
- package/esm2020/layout/breakpoints-observer.mjs +0 -105
- package/esm2020/layout/breakpoints.mjs +0 -29
- package/esm2020/layout/index.mjs +0 -9
- package/esm2020/layout/layout-module.mjs +0 -19
- package/esm2020/layout/layout_public_index.mjs +0 -5
- package/esm2020/layout/media-matcher.mjs +0 -85
- package/esm2020/layout/public-api.mjs +0 -12
- package/esm2020/listbox/index.mjs +0 -9
- package/esm2020/listbox/listbox-module.mjs +0 -24
- package/esm2020/listbox/listbox.mjs +0 -872
- package/esm2020/listbox/listbox_public_index.mjs +0 -5
- package/esm2020/listbox/public-api.mjs +0 -10
- package/esm2020/menu/context-menu-trigger.mjs +0 -212
- package/esm2020/menu/index.mjs +0 -9
- package/esm2020/menu/menu-aim.mjs +0 -203
- package/esm2020/menu/menu-bar.mjs +0 -133
- package/esm2020/menu/menu-base.mjs +0 -187
- package/esm2020/menu/menu-errors.mjs +0 -22
- package/esm2020/menu/menu-group.mjs +0 -30
- package/esm2020/menu/menu-interface.mjs +0 -11
- package/esm2020/menu/menu-item-checkbox.mjs +0 -49
- package/esm2020/menu/menu-item-radio.mjs +0 -71
- package/esm2020/menu/menu-item-selectable.mjs +0 -42
- package/esm2020/menu/menu-item.mjs +0 -267
- package/esm2020/menu/menu-module.mjs +0 -62
- package/esm2020/menu/menu-stack.mjs +0 -156
- package/esm2020/menu/menu-trigger-base.mjs +0 -107
- package/esm2020/menu/menu-trigger.mjs +0 -291
- package/esm2020/menu/menu.mjs +0 -134
- package/esm2020/menu/menu_public_index.mjs +0 -5
- package/esm2020/menu/pointer-focus-tracker.mjs +0 -51
- package/esm2020/menu/public-api.mjs +0 -24
- package/esm2020/observers/index.mjs +0 -9
- package/esm2020/observers/observe-content.mjs +0 -187
- package/esm2020/observers/observers_public_index.mjs +0 -5
- package/esm2020/observers/public-api.mjs +0 -9
- package/esm2020/overlay/dispatchers/base-overlay-dispatcher.mjs +0 -52
- package/esm2020/overlay/dispatchers/index.mjs +0 -10
- package/esm2020/overlay/dispatchers/overlay-keyboard-dispatcher.mjs +0 -81
- package/esm2020/overlay/dispatchers/overlay-outside-click-dispatcher.mjs +0 -138
- package/esm2020/overlay/fullscreen-overlay-container.mjs +0 -94
- package/esm2020/overlay/index.mjs +0 -9
- package/esm2020/overlay/overlay-config.mjs +0 -45
- package/esm2020/overlay/overlay-container.mjs +0 -81
- package/esm2020/overlay/overlay-directives.mjs +0 -427
- package/esm2020/overlay/overlay-module.mjs +0 -29
- package/esm2020/overlay/overlay-ref.mjs +0 -427
- package/esm2020/overlay/overlay-reference.mjs +0 -9
- package/esm2020/overlay/overlay.mjs +0 -125
- package/esm2020/overlay/overlay_public_index.mjs +0 -5
- package/esm2020/overlay/position/connected-position.mjs +0 -88
- package/esm2020/overlay/position/flexible-connected-position-strategy.mjs +0 -985
- package/esm2020/overlay/position/global-position-strategy.mjs +0 -237
- package/esm2020/overlay/position/overlay-position-builder.mjs +0 -50
- package/esm2020/overlay/position/position-strategy.mjs +0 -9
- package/esm2020/overlay/position/scroll-clip.mjs +0 -40
- package/esm2020/overlay/public-api.mjs +0 -22
- package/esm2020/overlay/scroll/block-scroll-strategy.mjs +0 -80
- package/esm2020/overlay/scroll/close-scroll-strategy.mjs +0 -61
- package/esm2020/overlay/scroll/index.mjs +0 -14
- package/esm2020/overlay/scroll/noop-scroll-strategy.mjs +0 -17
- package/esm2020/overlay/scroll/reposition-scroll-strategy.mjs +0 -61
- package/esm2020/overlay/scroll/scroll-strategy-options.mjs +0 -55
- package/esm2020/overlay/scroll/scroll-strategy.mjs +0 -14
- package/esm2020/platform/features/input-types.mjs +0 -59
- package/esm2020/platform/features/passive-listeners.mjs +0 -36
- package/esm2020/platform/features/scrolling.mjs +0 -85
- package/esm2020/platform/features/shadow-dom.mjs +0 -54
- package/esm2020/platform/features/test-environment.mjs +0 -24
- package/esm2020/platform/index.mjs +0 -9
- package/esm2020/platform/platform-module.mjs +0 -19
- package/esm2020/platform/platform.mjs +0 -85
- package/esm2020/platform/platform_public_index.mjs +0 -5
- package/esm2020/platform/public-api.mjs +0 -15
- package/esm2020/portal/dom-portal-outlet.mjs +0 -158
- package/esm2020/portal/index.mjs +0 -9
- package/esm2020/portal/portal-directives.mjs +0 -246
- package/esm2020/portal/portal-errors.mjs +0 -51
- package/esm2020/portal/portal-injector.mjs +0 -28
- package/esm2020/portal/portal.mjs +0 -188
- package/esm2020/portal/portal_public_index.mjs +0 -5
- package/esm2020/portal/public-api.mjs +0 -12
- package/esm2020/public-api.mjs +0 -9
- package/esm2020/scrolling/fixed-size-virtual-scroll.mjs +0 -217
- package/esm2020/scrolling/index.mjs +0 -9
- package/esm2020/scrolling/public-api.mjs +0 -20
- package/esm2020/scrolling/scroll-dispatcher.mjs +0 -163
- package/esm2020/scrolling/scrollable.mjs +0 -176
- package/esm2020/scrolling/scrolling-module.mjs +0 -67
- package/esm2020/scrolling/scrolling_public_index.mjs +0 -5
- package/esm2020/scrolling/viewport-ruler.mjs +0 -146
- package/esm2020/scrolling/virtual-for-of.mjs +0 -298
- package/esm2020/scrolling/virtual-scroll-repeater.mjs +0 -9
- package/esm2020/scrolling/virtual-scroll-strategy.mjs +0 -11
- package/esm2020/scrolling/virtual-scroll-viewport.mjs +0 -437
- package/esm2020/scrolling/virtual-scrollable-element.mjs +0 -41
- package/esm2020/scrolling/virtual-scrollable-window.mjs +0 -40
- package/esm2020/scrolling/virtual-scrollable.mjs +0 -40
- package/esm2020/stepper/index.mjs +0 -9
- package/esm2020/stepper/public-api.mjs +0 -13
- package/esm2020/stepper/step-header.mjs +0 -30
- package/esm2020/stepper/step-label.mjs +0 -23
- package/esm2020/stepper/stepper-button.mjs +0 -56
- package/esm2020/stepper/stepper-module.mjs +0 -40
- package/esm2020/stepper/stepper.mjs +0 -458
- package/esm2020/stepper/stepper_public_index.mjs +0 -5
- package/esm2020/table/can-stick.mjs +0 -44
- package/esm2020/table/cell.mjs +0 -217
- package/esm2020/table/coalesced-style-scheduler.mjs +0 -91
- package/esm2020/table/index.mjs +0 -9
- package/esm2020/table/public-api.mjs +0 -20
- package/esm2020/table/row.mjs +0 -262
- package/esm2020/table/sticky-position-listener.mjs +0 -11
- package/esm2020/table/sticky-styler.mjs +0 -345
- package/esm2020/table/table-errors.mjs +0 -67
- package/esm2020/table/table-module.mjs +0 -94
- package/esm2020/table/table.mjs +0 -1065
- package/esm2020/table/table_public_index.mjs +0 -5
- package/esm2020/table/text-column.mjs +0 -153
- package/esm2020/table/tokens.mjs +0 -16
- package/esm2020/text-field/autofill.mjs +0 -113
- package/esm2020/text-field/autosize.mjs +0 -309
- package/esm2020/text-field/index.mjs +0 -9
- package/esm2020/text-field/public-api.mjs +0 -11
- package/esm2020/text-field/text-field-module.mjs +0 -24
- package/esm2020/text-field/text-field_public_index.mjs +0 -5
- package/esm2020/tree/control/base-tree-control.mjs +0 -57
- package/esm2020/tree/control/flat-tree-control.mjs +0 -51
- package/esm2020/tree/control/nested-tree-control.mjs +0 -58
- package/esm2020/tree/control/tree-control.mjs +0 -2
- package/esm2020/tree/index.mjs +0 -9
- package/esm2020/tree/nested-node.mjs +0 -112
- package/esm2020/tree/node.mjs +0 -35
- package/esm2020/tree/outlet.mjs +0 -39
- package/esm2020/tree/padding.mjs +0 -131
- package/esm2020/tree/public-api.mjs +0 -20
- package/esm2020/tree/toggle.mjs +0 -50
- package/esm2020/tree/tree-errors.mjs +0 -43
- package/esm2020/tree/tree-module.mjs +0 -49
- package/esm2020/tree/tree.mjs +0 -347
- package/esm2020/tree/tree_public_index.mjs +0 -5
- package/esm2020/version.mjs +0 -11
- package/fesm2015/a11y.mjs +0 -2473
- package/fesm2015/a11y.mjs.map +0 -1
- package/fesm2015/accordion.mjs +0 -414
- package/fesm2015/accordion.mjs.map +0 -1
- package/fesm2015/bidi.mjs +0 -194
- package/fesm2015/bidi.mjs.map +0 -1
- package/fesm2015/cdk.mjs +0 -30
- package/fesm2015/cdk.mjs.map +0 -1
- package/fesm2015/clipboard.mjs +0 -263
- package/fesm2015/clipboard.mjs.map +0 -1
- package/fesm2015/coercion.mjs +0 -132
- package/fesm2015/coercion.mjs.map +0 -1
- package/fesm2015/collections.mjs +0 -519
- package/fesm2015/collections.mjs.map +0 -1
- package/fesm2015/dialog.mjs +0 -1050
- package/fesm2015/dialog.mjs.map +0 -1
- package/fesm2015/drag-drop.mjs +0 -3812
- package/fesm2015/drag-drop.mjs.map +0 -1
- package/fesm2015/keycodes.mjs.map +0 -1
- package/fesm2015/layout.mjs +0 -337
- package/fesm2015/layout.mjs.map +0 -1
- package/fesm2015/listbox.mjs +0 -1200
- package/fesm2015/listbox.mjs.map +0 -1
- package/fesm2015/menu.mjs +0 -2719
- package/fesm2015/menu.mjs.map +0 -1
- package/fesm2015/observers.mjs +0 -326
- package/fesm2015/observers.mjs.map +0 -1
- package/fesm2015/overlay.mjs +0 -3137
- package/fesm2015/overlay.mjs.map +0 -1
- package/fesm2015/platform.mjs +0 -385
- package/fesm2015/platform.mjs.map +0 -1
- package/fesm2015/portal.mjs +0 -691
- package/fesm2015/portal.mjs.map +0 -1
- package/fesm2015/scrolling.mjs.map +0 -1
- package/fesm2015/stepper.mjs +0 -989
- package/fesm2015/stepper.mjs.map +0 -1
- package/fesm2015/table.mjs +0 -2356
- package/fesm2015/table.mjs.map +0 -1
- package/fesm2015/testing.mjs +0 -833
- package/fesm2015/testing.mjs.map +0 -1
- package/fesm2015/text-field.mjs +0 -461
- package/fesm2015/text-field.mjs.map +0 -1
- package/fesm2015/tree.mjs +0 -1303
- package/fesm2015/tree.mjs.map +0 -1
- package/fesm2020/a11y.mjs +0 -2476
- package/fesm2020/a11y.mjs.map +0 -1
- package/fesm2020/accordion.mjs +0 -414
- package/fesm2020/accordion.mjs.map +0 -1
- package/fesm2020/bidi.mjs +0 -192
- package/fesm2020/bidi.mjs.map +0 -1
- package/fesm2020/cdk.mjs +0 -30
- package/fesm2020/cdk.mjs.map +0 -1
- package/fesm2020/clipboard.mjs.map +0 -1
- package/fesm2020/coercion.mjs +0 -132
- package/fesm2020/coercion.mjs.map +0 -1
- package/fesm2020/collections.mjs +0 -535
- package/fesm2020/collections.mjs.map +0 -1
- package/fesm2020/dialog.mjs.map +0 -1
- package/fesm2020/drag-drop.mjs.map +0 -1
- package/fesm2020/keycodes.mjs +0 -167
- package/fesm2020/keycodes.mjs.map +0 -1
- package/fesm2020/layout.mjs +0 -337
- package/fesm2020/layout.mjs.map +0 -1
- package/fesm2020/listbox.mjs +0 -1164
- package/fesm2020/listbox.mjs.map +0 -1
- package/fesm2020/menu.mjs +0 -2615
- package/fesm2020/menu.mjs.map +0 -1
- package/fesm2020/observers.mjs +0 -325
- package/fesm2020/observers.mjs.map +0 -1
- package/fesm2020/overlay.mjs.map +0 -1
- package/fesm2020/platform.mjs +0 -383
- package/fesm2020/platform.mjs.map +0 -1
- package/fesm2020/portal.mjs.map +0 -1
- package/fesm2020/scrolling.mjs +0 -1591
- package/fesm2020/scrolling.mjs.map +0 -1
- package/fesm2020/stepper.mjs +0 -985
- package/fesm2020/stepper.mjs.map +0 -1
- package/fesm2020/table.mjs.map +0 -1
- package/fesm2020/testing.mjs +0 -797
- package/fesm2020/testing.mjs.map +0 -1
- package/fesm2020/text-field.mjs.map +0 -1
- package/fesm2020/tree.mjs +0 -1305
- package/fesm2020/tree.mjs.map +0 -1
- package/overlay/_index.import.scss +0 -13
- package/text-field/_index.import.scss +0 -2
|
@@ -0,0 +1,950 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
/** Subject used to dispatch and listen for changes to the auto change detection status . */
|
|
4
|
+
const autoChangeDetectionSubject = new BehaviorSubject({
|
|
5
|
+
isDisabled: false,
|
|
6
|
+
});
|
|
7
|
+
/** The current subscription to `autoChangeDetectionSubject`. */
|
|
8
|
+
let autoChangeDetectionSubscription;
|
|
9
|
+
/**
|
|
10
|
+
* The default handler for auto change detection status changes. This handler will be used if the
|
|
11
|
+
* specific environment does not install its own.
|
|
12
|
+
* @param status The new auto change detection status.
|
|
13
|
+
*/
|
|
14
|
+
function defaultAutoChangeDetectionHandler(status) {
|
|
15
|
+
status.onDetectChangesNow?.();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Allows a test `HarnessEnvironment` to install its own handler for auto change detection status
|
|
19
|
+
* changes.
|
|
20
|
+
* @param handler The handler for the auto change detection status.
|
|
21
|
+
*/
|
|
22
|
+
function handleAutoChangeDetectionStatus(handler) {
|
|
23
|
+
stopHandlingAutoChangeDetectionStatus();
|
|
24
|
+
autoChangeDetectionSubscription = autoChangeDetectionSubject.subscribe(handler);
|
|
25
|
+
}
|
|
26
|
+
/** Allows a `HarnessEnvironment` to stop handling auto change detection status changes. */
|
|
27
|
+
function stopHandlingAutoChangeDetectionStatus() {
|
|
28
|
+
autoChangeDetectionSubscription?.unsubscribe();
|
|
29
|
+
autoChangeDetectionSubscription = null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Batches together triggering of change detection over the duration of the given function.
|
|
33
|
+
* @param fn The function to call with batched change detection.
|
|
34
|
+
* @param triggerBeforeAndAfter Optionally trigger change detection once before and after the batch
|
|
35
|
+
* operation. If false, change detection will not be triggered.
|
|
36
|
+
* @return The result of the given function.
|
|
37
|
+
*/
|
|
38
|
+
async function batchChangeDetection(fn, triggerBeforeAndAfter) {
|
|
39
|
+
// If change detection batching is already in progress, just run the function.
|
|
40
|
+
if (autoChangeDetectionSubject.getValue().isDisabled) {
|
|
41
|
+
return await fn();
|
|
42
|
+
}
|
|
43
|
+
// If nothing is handling change detection batching, install the default handler.
|
|
44
|
+
if (!autoChangeDetectionSubscription) {
|
|
45
|
+
handleAutoChangeDetectionStatus(defaultAutoChangeDetectionHandler);
|
|
46
|
+
}
|
|
47
|
+
if (triggerBeforeAndAfter) {
|
|
48
|
+
await new Promise(resolve => autoChangeDetectionSubject.next({
|
|
49
|
+
isDisabled: true,
|
|
50
|
+
onDetectChangesNow: resolve,
|
|
51
|
+
}));
|
|
52
|
+
// The function passed in may throw (e.g. if the user wants to make an expectation of an error
|
|
53
|
+
// being thrown. If this happens, we need to make sure we still re-enable change detection, so
|
|
54
|
+
// we wrap it in a `finally` block.
|
|
55
|
+
try {
|
|
56
|
+
return await fn();
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await new Promise(resolve => autoChangeDetectionSubject.next({
|
|
60
|
+
isDisabled: false,
|
|
61
|
+
onDetectChangesNow: resolve,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
autoChangeDetectionSubject.next({ isDisabled: true });
|
|
67
|
+
// The function passed in may throw (e.g. if the user wants to make an expectation of an error
|
|
68
|
+
// being thrown. If this happens, we need to make sure we still re-enable change detection, so
|
|
69
|
+
// we wrap it in a `finally` block.
|
|
70
|
+
try {
|
|
71
|
+
return await fn();
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
autoChangeDetectionSubject.next({ isDisabled: false });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Disables the harness system's auto change detection for the duration of the given function.
|
|
80
|
+
* @param fn The function to disable auto change detection for.
|
|
81
|
+
* @return The result of the given function.
|
|
82
|
+
*/
|
|
83
|
+
async function manualChangeDetection(fn) {
|
|
84
|
+
return batchChangeDetection(fn, false);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Resolves the given list of async values in parallel (i.e. via Promise.all) while batching change
|
|
88
|
+
* detection over the entire operation such that change detection occurs exactly once before
|
|
89
|
+
* resolving the values and once after.
|
|
90
|
+
* @param values A getter for the async values to resolve in parallel with batched change detection.
|
|
91
|
+
* @return The resolved values.
|
|
92
|
+
*/
|
|
93
|
+
async function parallel(values) {
|
|
94
|
+
return batchChangeDetection(() => Promise.all(values()), true);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Base class for component test harnesses that all component harness authors should extend. This
|
|
99
|
+
* base component harness provides the basic ability to locate element and sub-component harnesses.
|
|
100
|
+
*/
|
|
101
|
+
class ComponentHarness {
|
|
102
|
+
locatorFactory;
|
|
103
|
+
constructor(locatorFactory) {
|
|
104
|
+
this.locatorFactory = locatorFactory;
|
|
105
|
+
}
|
|
106
|
+
/** Gets a `Promise` for the `TestElement` representing the host element of the component. */
|
|
107
|
+
async host() {
|
|
108
|
+
return this.locatorFactory.rootElement;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets a `LocatorFactory` for the document root element. This factory can be used to create
|
|
112
|
+
* locators for elements that a component creates outside of its own root element. (e.g. by
|
|
113
|
+
* appending to document.body).
|
|
114
|
+
*/
|
|
115
|
+
documentRootLocatorFactory() {
|
|
116
|
+
return this.locatorFactory.documentRootLocatorFactory();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
120
|
+
* or element under the host element of this `ComponentHarness`.
|
|
121
|
+
*
|
|
122
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
123
|
+
*
|
|
124
|
+
* ```html
|
|
125
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* then we expect:
|
|
129
|
+
*
|
|
130
|
+
* ```ts
|
|
131
|
+
* await ch.locatorFor(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
132
|
+
* await ch.locatorFor('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
133
|
+
* await ch.locatorFor('span')() // Throws because the `Promise` rejects
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
137
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
138
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
139
|
+
* given class.
|
|
140
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
141
|
+
* predicate.
|
|
142
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for the
|
|
143
|
+
* first element or harness matching the given search criteria. Matches are ordered first by
|
|
144
|
+
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
145
|
+
* `Promise` rejects. The type that the `Promise` resolves to is a union of all result types for
|
|
146
|
+
* each query.
|
|
147
|
+
*/
|
|
148
|
+
locatorFor(...queries) {
|
|
149
|
+
return this.locatorFactory.locatorFor(...queries);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
153
|
+
* or element under the host element of this `ComponentHarness`.
|
|
154
|
+
*
|
|
155
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
156
|
+
*
|
|
157
|
+
* ```html
|
|
158
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* then we expect:
|
|
162
|
+
*
|
|
163
|
+
* ```ts
|
|
164
|
+
* await ch.locatorForOptional(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
165
|
+
* await ch.locatorForOptional('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
166
|
+
* await ch.locatorForOptional('span')() // Gets `null`
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
170
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
171
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
172
|
+
* given class.
|
|
173
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
174
|
+
* predicate.
|
|
175
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for the
|
|
176
|
+
* first element or harness matching the given search criteria. Matches are ordered first by
|
|
177
|
+
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
178
|
+
* `Promise` is resolved with `null`. The type that the `Promise` resolves to is a union of all
|
|
179
|
+
* result types for each query or null.
|
|
180
|
+
*/
|
|
181
|
+
locatorForOptional(...queries) {
|
|
182
|
+
return this.locatorFactory.locatorForOptional(...queries);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Creates an asynchronous locator function that can be used to find `ComponentHarness` instances
|
|
186
|
+
* or elements under the host element of this `ComponentHarness`.
|
|
187
|
+
*
|
|
188
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'` and
|
|
189
|
+
* `IdIsD1Harness.hostSelector` is `'#d1'`
|
|
190
|
+
*
|
|
191
|
+
* ```html
|
|
192
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* then we expect:
|
|
196
|
+
*
|
|
197
|
+
* ```ts
|
|
198
|
+
* // Gets [DivHarness for #d1, TestElement for #d1, DivHarness for #d2, TestElement for #d2]
|
|
199
|
+
* await ch.locatorForAll(DivHarness, 'div')()
|
|
200
|
+
* // Gets [TestElement for #d1, TestElement for #d2]
|
|
201
|
+
* await ch.locatorForAll('div', '#d1')()
|
|
202
|
+
* // Gets [DivHarness for #d1, IdIsD1Harness for #d1, DivHarness for #d2]
|
|
203
|
+
* await ch.locatorForAll(DivHarness, IdIsD1Harness)()
|
|
204
|
+
* // Gets []
|
|
205
|
+
* await ch.locatorForAll('span')()
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
209
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
210
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
211
|
+
* given class.
|
|
212
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
213
|
+
* predicate.
|
|
214
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for all
|
|
215
|
+
* elements and harnesses matching the given search criteria. Matches are ordered first by
|
|
216
|
+
* order in the DOM, and second by order in the queries list. If an element matches more than
|
|
217
|
+
* one `ComponentHarness` class, the locator gets an instance of each for the same element. If
|
|
218
|
+
* an element matches multiple `string` selectors, only one `TestElement` instance is returned
|
|
219
|
+
* for that element. The type that the `Promise` resolves to is an array where each element is
|
|
220
|
+
* the union of all result types for each query.
|
|
221
|
+
*/
|
|
222
|
+
locatorForAll(...queries) {
|
|
223
|
+
return this.locatorFactory.locatorForAll(...queries);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Flushes change detection and async tasks in the Angular zone.
|
|
227
|
+
* In most cases it should not be necessary to call this manually. However, there may be some edge
|
|
228
|
+
* cases where it is needed to fully flush animation events.
|
|
229
|
+
*/
|
|
230
|
+
async forceStabilize() {
|
|
231
|
+
return this.locatorFactory.forceStabilize();
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Waits for all scheduled or running async tasks to complete. This allows harness
|
|
235
|
+
* authors to wait for async tasks outside of the Angular zone.
|
|
236
|
+
*/
|
|
237
|
+
async waitForTasksOutsideAngular() {
|
|
238
|
+
return this.locatorFactory.waitForTasksOutsideAngular();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Base class for component harnesses that authors should extend if they anticipate that consumers
|
|
243
|
+
* of the harness may want to access other harnesses within the `<ng-content>` of the component.
|
|
244
|
+
*/
|
|
245
|
+
class ContentContainerComponentHarness extends ComponentHarness {
|
|
246
|
+
/**
|
|
247
|
+
* Gets a `HarnessLoader` that searches for harnesses under the first element matching the given
|
|
248
|
+
* selector within the current harness's content.
|
|
249
|
+
* @param selector The selector for an element in the component's content.
|
|
250
|
+
* @returns A `HarnessLoader` that searches for harnesses under the given selector.
|
|
251
|
+
*/
|
|
252
|
+
async getChildLoader(selector) {
|
|
253
|
+
return (await this.getRootHarnessLoader()).getChildLoader(selector);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Gets a list of `HarnessLoader` for each element matching the given selector under the current
|
|
257
|
+
* harness's cotnent that searches for harnesses under that element.
|
|
258
|
+
* @param selector The selector for elements in the component's content.
|
|
259
|
+
* @returns A list of `HarnessLoader` for each element matching the given selector.
|
|
260
|
+
*/
|
|
261
|
+
async getAllChildLoaders(selector) {
|
|
262
|
+
return (await this.getRootHarnessLoader()).getAllChildLoaders(selector);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Gets the first matching harness for the given query within the current harness's content.
|
|
266
|
+
* @param query The harness query to search for.
|
|
267
|
+
* @returns The first harness matching the given query.
|
|
268
|
+
* @throws If no matching harness is found.
|
|
269
|
+
*/
|
|
270
|
+
async getHarness(query) {
|
|
271
|
+
return (await this.getRootHarnessLoader()).getHarness(query);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Gets the first matching harness for the given query within the current harness's content.
|
|
275
|
+
* @param query The harness query to search for.
|
|
276
|
+
* @returns The first harness matching the given query, or null if none is found.
|
|
277
|
+
*/
|
|
278
|
+
async getHarnessOrNull(query) {
|
|
279
|
+
return (await this.getRootHarnessLoader()).getHarnessOrNull(query);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Gets a matching harness for the given query and index within the current harness's content.
|
|
283
|
+
* @param query The harness query to search for.
|
|
284
|
+
* @param index The zero-indexed offset of the component to find.
|
|
285
|
+
* @returns The first harness matching the given query.
|
|
286
|
+
* @throws If no matching harness is found.
|
|
287
|
+
*/
|
|
288
|
+
async getHarnessAtIndex(query, index) {
|
|
289
|
+
return (await this.getRootHarnessLoader()).getHarnessAtIndex(query, index);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Gets all matching harnesses for the given query within the current harness's content.
|
|
293
|
+
* @param query The harness query to search for.
|
|
294
|
+
* @returns The list of harness matching the given query.
|
|
295
|
+
*/
|
|
296
|
+
async getAllHarnesses(query) {
|
|
297
|
+
return (await this.getRootHarnessLoader()).getAllHarnesses(query);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Returns the number of matching harnesses for the given query within the current harness's
|
|
301
|
+
* content.
|
|
302
|
+
*
|
|
303
|
+
* @param query The harness query to search for.
|
|
304
|
+
* @returns The number of matching harnesses for the given query.
|
|
305
|
+
*/
|
|
306
|
+
async countHarnesses(query) {
|
|
307
|
+
return (await this.getRootHarnessLoader()).countHarnesses(query);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Checks whether there is a matching harnesses for the given query within the current harness's
|
|
311
|
+
* content.
|
|
312
|
+
*
|
|
313
|
+
* @param query The harness query to search for.
|
|
314
|
+
* @returns Whether there is matching harnesses for the given query.
|
|
315
|
+
*/
|
|
316
|
+
async hasHarness(query) {
|
|
317
|
+
return (await this.getRootHarnessLoader()).hasHarness(query);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Gets the root harness loader from which to start
|
|
321
|
+
* searching for content contained by this harness.
|
|
322
|
+
*/
|
|
323
|
+
async getRootHarnessLoader() {
|
|
324
|
+
return this.locatorFactory.rootHarnessLoader();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* A class used to associate a ComponentHarness class with predicate functions that can be used to
|
|
329
|
+
* filter instances of the class to be matched.
|
|
330
|
+
*/
|
|
331
|
+
class HarnessPredicate {
|
|
332
|
+
harnessType;
|
|
333
|
+
_predicates = [];
|
|
334
|
+
_descriptions = [];
|
|
335
|
+
_ancestor;
|
|
336
|
+
constructor(harnessType, options) {
|
|
337
|
+
this.harnessType = harnessType;
|
|
338
|
+
this._addBaseOptions(options);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Checks if the specified nullable string value matches the given pattern.
|
|
342
|
+
* @param value The nullable string value to check, or a Promise resolving to the
|
|
343
|
+
* nullable string value.
|
|
344
|
+
* @param pattern The pattern the value is expected to match. If `pattern` is a string,
|
|
345
|
+
* `value` is expected to match exactly. If `pattern` is a regex, a partial match is
|
|
346
|
+
* allowed. If `pattern` is `null`, the value is expected to be `null`.
|
|
347
|
+
* @return Whether the value matches the pattern.
|
|
348
|
+
*/
|
|
349
|
+
static async stringMatches(value, pattern) {
|
|
350
|
+
value = await value;
|
|
351
|
+
if (pattern === null) {
|
|
352
|
+
return value === null;
|
|
353
|
+
}
|
|
354
|
+
else if (value === null) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
return typeof pattern === 'string' ? value === pattern : pattern.test(value);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Adds a predicate function to be run against candidate harnesses.
|
|
361
|
+
* @param description A description of this predicate that may be used in error messages.
|
|
362
|
+
* @param predicate An async predicate function.
|
|
363
|
+
* @return this (for method chaining).
|
|
364
|
+
*/
|
|
365
|
+
add(description, predicate) {
|
|
366
|
+
this._descriptions.push(description);
|
|
367
|
+
this._predicates.push(predicate);
|
|
368
|
+
return this;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Adds a predicate function that depends on an option value to be run against candidate
|
|
372
|
+
* harnesses. If the option value is undefined, the predicate will be ignored.
|
|
373
|
+
* @param name The name of the option (may be used in error messages).
|
|
374
|
+
* @param option The option value.
|
|
375
|
+
* @param predicate The predicate function to run if the option value is not undefined.
|
|
376
|
+
* @return this (for method chaining).
|
|
377
|
+
*/
|
|
378
|
+
addOption(name, option, predicate) {
|
|
379
|
+
if (option !== undefined) {
|
|
380
|
+
this.add(`${name} = ${_valueAsString(option)}`, item => predicate(item, option));
|
|
381
|
+
}
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Filters a list of harnesses on this predicate.
|
|
386
|
+
* @param harnesses The list of harnesses to filter.
|
|
387
|
+
* @return A list of harnesses that satisfy this predicate.
|
|
388
|
+
*/
|
|
389
|
+
async filter(harnesses) {
|
|
390
|
+
if (harnesses.length === 0) {
|
|
391
|
+
return [];
|
|
392
|
+
}
|
|
393
|
+
const results = await parallel(() => harnesses.map(h => this.evaluate(h)));
|
|
394
|
+
return harnesses.filter((_, i) => results[i]);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Evaluates whether the given harness satisfies this predicate.
|
|
398
|
+
* @param harness The harness to check
|
|
399
|
+
* @return A promise that resolves to true if the harness satisfies this predicate,
|
|
400
|
+
* and resolves to false otherwise.
|
|
401
|
+
*/
|
|
402
|
+
async evaluate(harness) {
|
|
403
|
+
const results = await parallel(() => this._predicates.map(p => p(harness)));
|
|
404
|
+
return results.reduce((combined, current) => combined && current, true);
|
|
405
|
+
}
|
|
406
|
+
/** Gets a description of this predicate for use in error messages. */
|
|
407
|
+
getDescription() {
|
|
408
|
+
return this._descriptions.join(', ');
|
|
409
|
+
}
|
|
410
|
+
/** Gets the selector used to find candidate elements. */
|
|
411
|
+
getSelector() {
|
|
412
|
+
// We don't have to go through the extra trouble if there are no ancestors.
|
|
413
|
+
if (!this._ancestor) {
|
|
414
|
+
return (this.harnessType.hostSelector || '').trim();
|
|
415
|
+
}
|
|
416
|
+
const [ancestors, ancestorPlaceholders] = _splitAndEscapeSelector(this._ancestor);
|
|
417
|
+
const [selectors, selectorPlaceholders] = _splitAndEscapeSelector(this.harnessType.hostSelector || '');
|
|
418
|
+
const result = [];
|
|
419
|
+
// We have to add the ancestor to each part of the host compound selector, otherwise we can get
|
|
420
|
+
// incorrect results. E.g. `.ancestor .a, .ancestor .b` vs `.ancestor .a, .b`.
|
|
421
|
+
ancestors.forEach(escapedAncestor => {
|
|
422
|
+
const ancestor = _restoreSelector(escapedAncestor, ancestorPlaceholders);
|
|
423
|
+
return selectors.forEach(escapedSelector => result.push(`${ancestor} ${_restoreSelector(escapedSelector, selectorPlaceholders)}`));
|
|
424
|
+
});
|
|
425
|
+
return result.join(', ');
|
|
426
|
+
}
|
|
427
|
+
/** Adds base options common to all harness types. */
|
|
428
|
+
_addBaseOptions(options) {
|
|
429
|
+
this._ancestor = options.ancestor || '';
|
|
430
|
+
if (this._ancestor) {
|
|
431
|
+
this._descriptions.push(`has ancestor matching selector "${this._ancestor}"`);
|
|
432
|
+
}
|
|
433
|
+
const selector = options.selector;
|
|
434
|
+
if (selector !== undefined) {
|
|
435
|
+
this.add(`host matches selector "${selector}"`, async (item) => {
|
|
436
|
+
return (await item.host()).matchesSelector(selector);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
/** Represent a value as a string for the purpose of logging. */
|
|
442
|
+
function _valueAsString(value) {
|
|
443
|
+
if (value === undefined) {
|
|
444
|
+
return 'undefined';
|
|
445
|
+
}
|
|
446
|
+
try {
|
|
447
|
+
// `JSON.stringify` doesn't handle RegExp properly, so we need a custom replacer.
|
|
448
|
+
// Use a character that is unlikely to appear in real strings to denote the start and end of
|
|
449
|
+
// the regex. This allows us to strip out the extra quotes around the value added by
|
|
450
|
+
// `JSON.stringify`. Also do custom escaping on `"` characters to prevent `JSON.stringify`
|
|
451
|
+
// from escaping them as if they were part of a string.
|
|
452
|
+
const stringifiedValue = JSON.stringify(value, (_, v) => v instanceof RegExp
|
|
453
|
+
? `◬MAT_RE_ESCAPE◬${v.toString().replace(/"/g, '◬MAT_RE_ESCAPE◬')}◬MAT_RE_ESCAPE◬`
|
|
454
|
+
: v);
|
|
455
|
+
// Strip out the extra quotes around regexes and put back the manually escaped `"` characters.
|
|
456
|
+
return stringifiedValue
|
|
457
|
+
.replace(/"◬MAT_RE_ESCAPE◬|◬MAT_RE_ESCAPE◬"/g, '')
|
|
458
|
+
.replace(/◬MAT_RE_ESCAPE◬/g, '"');
|
|
459
|
+
}
|
|
460
|
+
catch {
|
|
461
|
+
// `JSON.stringify` will throw if the object is cyclical,
|
|
462
|
+
// in this case the best we can do is report the value as `{...}`.
|
|
463
|
+
return '{...}';
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Splits up a compound selector into its parts and escapes any quoted content. The quoted content
|
|
468
|
+
* has to be escaped, because it can contain commas which will throw throw us off when trying to
|
|
469
|
+
* split it.
|
|
470
|
+
* @param selector Selector to be split.
|
|
471
|
+
* @returns The escaped string where any quoted content is replaced with a placeholder. E.g.
|
|
472
|
+
* `[foo="bar"]` turns into `[foo=__cdkPlaceholder-0__]`. Use `_restoreSelector` to restore
|
|
473
|
+
* the placeholders.
|
|
474
|
+
*/
|
|
475
|
+
function _splitAndEscapeSelector(selector) {
|
|
476
|
+
const placeholders = [];
|
|
477
|
+
// Note that the regex doesn't account for nested quotes so something like `"ab'cd'e"` will be
|
|
478
|
+
// considered as two blocks. It's a bit of an edge case, but if we find that it's a problem,
|
|
479
|
+
// we can make it a bit smarter using a loop. Use this for now since it's more readable and
|
|
480
|
+
// compact. More complete implementation:
|
|
481
|
+
// https://github.com/angular/angular/blob/bd34bc9e89f18a/packages/compiler/src/shadow_css.ts#L655
|
|
482
|
+
const result = selector.replace(/(["'][^["']*["'])/g, (_, keep) => {
|
|
483
|
+
const replaceBy = `__cdkPlaceholder-${placeholders.length}__`;
|
|
484
|
+
placeholders.push(keep);
|
|
485
|
+
return replaceBy;
|
|
486
|
+
});
|
|
487
|
+
return [result.split(',').map(part => part.trim()), placeholders];
|
|
488
|
+
}
|
|
489
|
+
/** Restores a selector whose content was escaped in `_splitAndEscapeSelector`. */
|
|
490
|
+
function _restoreSelector(selector, placeholders) {
|
|
491
|
+
return selector.replace(/__cdkPlaceholder-(\d+)__/g, (_, index) => placeholders[+index]);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Base harness environment class that can be extended to allow `ComponentHarness`es to be used in
|
|
496
|
+
* different test environments (e.g. testbed, protractor, etc.). This class implements the
|
|
497
|
+
* functionality of both a `HarnessLoader` and `LocatorFactory`. This class is generic on the raw
|
|
498
|
+
* element type, `E`, used by the particular test environment.
|
|
499
|
+
*/
|
|
500
|
+
class HarnessEnvironment {
|
|
501
|
+
rawRootElement;
|
|
502
|
+
/** The root element of this `HarnessEnvironment` as a `TestElement`. */
|
|
503
|
+
get rootElement() {
|
|
504
|
+
this._rootElement = this._rootElement || this.createTestElement(this.rawRootElement);
|
|
505
|
+
return this._rootElement;
|
|
506
|
+
}
|
|
507
|
+
set rootElement(element) {
|
|
508
|
+
this._rootElement = element;
|
|
509
|
+
}
|
|
510
|
+
_rootElement;
|
|
511
|
+
constructor(
|
|
512
|
+
/** The native root element of this `HarnessEnvironment`. */
|
|
513
|
+
rawRootElement) {
|
|
514
|
+
this.rawRootElement = rawRootElement;
|
|
515
|
+
}
|
|
516
|
+
/** Gets a locator factory rooted at the document root. */
|
|
517
|
+
documentRootLocatorFactory() {
|
|
518
|
+
return this.createEnvironment(this.getDocumentRoot());
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
522
|
+
* or element under the root element of this `HarnessEnvironment`.
|
|
523
|
+
*
|
|
524
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
525
|
+
*
|
|
526
|
+
* ```html
|
|
527
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* then we expect:
|
|
531
|
+
*
|
|
532
|
+
* ```ts
|
|
533
|
+
* await lf.locatorFor(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
534
|
+
* await lf.locatorFor('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
535
|
+
* await lf.locatorFor('span')() // Throws because the `Promise` rejects
|
|
536
|
+
* ```
|
|
537
|
+
*
|
|
538
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
539
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
540
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
541
|
+
* given class.
|
|
542
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
543
|
+
* predicate.
|
|
544
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for the
|
|
545
|
+
* first element or harness matching the given search criteria. Matches are ordered first by
|
|
546
|
+
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
547
|
+
* `Promise` rejects. The type that the `Promise` resolves to is a union of all result types for
|
|
548
|
+
* each query.
|
|
549
|
+
*/
|
|
550
|
+
locatorFor(...queries) {
|
|
551
|
+
return () => _assertResultFound(this._getAllHarnessesAndTestElements(queries), _getDescriptionForLocatorForQueries(queries));
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
|
|
555
|
+
* or element under the root element of this `HarnessEnvironmnet`.
|
|
556
|
+
*
|
|
557
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'`
|
|
558
|
+
*
|
|
559
|
+
* ```html
|
|
560
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
561
|
+
* ```
|
|
562
|
+
*
|
|
563
|
+
* then we expect:
|
|
564
|
+
*
|
|
565
|
+
* ```ts
|
|
566
|
+
* await lf.locatorForOptional(DivHarness, 'div')() // Gets a `DivHarness` instance for #d1
|
|
567
|
+
* await lf.locatorForOptional('div', DivHarness)() // Gets a `TestElement` instance for #d1
|
|
568
|
+
* await lf.locatorForOptional('span')() // Gets `null`
|
|
569
|
+
* ```
|
|
570
|
+
*
|
|
571
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
572
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
573
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
574
|
+
* given class.
|
|
575
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
576
|
+
* predicate.
|
|
577
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for the
|
|
578
|
+
* first element or harness matching the given search criteria. Matches are ordered first by
|
|
579
|
+
* order in the DOM, and second by order in the queries list. If no matches are found, the
|
|
580
|
+
* `Promise` is resolved with `null`. The type that the `Promise` resolves to is a union of all
|
|
581
|
+
* result types for each query or null.
|
|
582
|
+
*/
|
|
583
|
+
locatorForOptional(...queries) {
|
|
584
|
+
return async () => (await this._getAllHarnessesAndTestElements(queries))[0] || null;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Creates an asynchronous locator function that can be used to find `ComponentHarness` instances
|
|
588
|
+
* or elements under the root element of this `HarnessEnvironment`.
|
|
589
|
+
*
|
|
590
|
+
* For example, given the following DOM and assuming `DivHarness.hostSelector` is `'div'` and
|
|
591
|
+
* `IdIsD1Harness.hostSelector` is `'#d1'`
|
|
592
|
+
*
|
|
593
|
+
* ```html
|
|
594
|
+
* <div id="d1"></div><div id="d2"></div>
|
|
595
|
+
* ```
|
|
596
|
+
*
|
|
597
|
+
* then we expect:
|
|
598
|
+
*
|
|
599
|
+
* ```ts
|
|
600
|
+
* // Gets [DivHarness for #d1, TestElement for #d1, DivHarness for #d2, TestElement for #d2]
|
|
601
|
+
* await lf.locatorForAll(DivHarness, 'div')()
|
|
602
|
+
* // Gets [TestElement for #d1, TestElement for #d2]
|
|
603
|
+
* await lf.locatorForAll('div', '#d1')()
|
|
604
|
+
* // Gets [DivHarness for #d1, IdIsD1Harness for #d1, DivHarness for #d2]
|
|
605
|
+
* await lf.locatorForAll(DivHarness, IdIsD1Harness)()
|
|
606
|
+
* // Gets []
|
|
607
|
+
* await lf.locatorForAll('span')()
|
|
608
|
+
* ```
|
|
609
|
+
*
|
|
610
|
+
* @param queries A list of queries specifying which harnesses and elements to search for:
|
|
611
|
+
* - A `string` searches for elements matching the CSS selector specified by the string.
|
|
612
|
+
* - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
|
|
613
|
+
* given class.
|
|
614
|
+
* - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
|
|
615
|
+
* predicate.
|
|
616
|
+
* @return An asynchronous locator function that searches for and returns a `Promise` for all
|
|
617
|
+
* elements and harnesses matching the given search criteria. Matches are ordered first by
|
|
618
|
+
* order in the DOM, and second by order in the queries list. If an element matches more than
|
|
619
|
+
* one `ComponentHarness` class, the locator gets an instance of each for the same element. If
|
|
620
|
+
* an element matches multiple `string` selectors, only one `TestElement` instance is returned
|
|
621
|
+
* for that element. The type that the `Promise` resolves to is an array where each element is
|
|
622
|
+
* the union of all result types for each query.
|
|
623
|
+
*/
|
|
624
|
+
locatorForAll(...queries) {
|
|
625
|
+
return () => this._getAllHarnessesAndTestElements(queries);
|
|
626
|
+
}
|
|
627
|
+
/** @return A `HarnessLoader` rooted at the root element of this `HarnessEnvironment`. */
|
|
628
|
+
async rootHarnessLoader() {
|
|
629
|
+
return this;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Gets a `HarnessLoader` instance for an element under the root of this `HarnessEnvironment`.
|
|
633
|
+
* @param selector The selector for the root element.
|
|
634
|
+
* @return A `HarnessLoader` rooted at the first element matching the given selector.
|
|
635
|
+
* @throws If no matching element is found for the given selector.
|
|
636
|
+
*/
|
|
637
|
+
async harnessLoaderFor(selector) {
|
|
638
|
+
return this.createEnvironment(await _assertResultFound(this.getAllRawElements(selector), [
|
|
639
|
+
_getDescriptionForHarnessLoaderQuery(selector),
|
|
640
|
+
]));
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Gets a `HarnessLoader` instance for an element under the root of this `HarnessEnvironment`.
|
|
644
|
+
* @param selector The selector for the root element.
|
|
645
|
+
* @return A `HarnessLoader` rooted at the first element matching the given selector, or null if
|
|
646
|
+
* no matching element is found.
|
|
647
|
+
*/
|
|
648
|
+
async harnessLoaderForOptional(selector) {
|
|
649
|
+
const elements = await this.getAllRawElements(selector);
|
|
650
|
+
return elements[0] ? this.createEnvironment(elements[0]) : null;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Gets a list of `HarnessLoader` instances, one for each matching element.
|
|
654
|
+
* @param selector The selector for the root element.
|
|
655
|
+
* @return A list of `HarnessLoader`, one rooted at each element matching the given selector.
|
|
656
|
+
*/
|
|
657
|
+
async harnessLoaderForAll(selector) {
|
|
658
|
+
const elements = await this.getAllRawElements(selector);
|
|
659
|
+
return elements.map(element => this.createEnvironment(element));
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Searches for an instance of the component corresponding to the given harness type under the
|
|
663
|
+
* `HarnessEnvironment`'s root element, and returns a `ComponentHarness` for that instance. If
|
|
664
|
+
* multiple matching components are found, a harness for the first one is returned. If no matching
|
|
665
|
+
* component is found, an error is thrown.
|
|
666
|
+
* @param query A query for a harness to create
|
|
667
|
+
* @return An instance of the given harness type
|
|
668
|
+
* @throws If a matching component instance can't be found.
|
|
669
|
+
*/
|
|
670
|
+
getHarness(query) {
|
|
671
|
+
return this.locatorFor(query)();
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Searches for an instance of the component corresponding to the given harness type under the
|
|
675
|
+
* `HarnessEnvironment`'s root element, and returns a `ComponentHarness` for that instance. If
|
|
676
|
+
* multiple matching components are found, a harness for the first one is returned. If no matching
|
|
677
|
+
* component is found, null is returned.
|
|
678
|
+
* @param query A query for a harness to create
|
|
679
|
+
* @return An instance of the given harness type (or null if not found).
|
|
680
|
+
*/
|
|
681
|
+
getHarnessOrNull(query) {
|
|
682
|
+
return this.locatorForOptional(query)();
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Searches for an instance of the component corresponding to the given harness type and index
|
|
686
|
+
* under the `HarnessEnvironment`'s root element, and returns a `ComponentHarness` for that
|
|
687
|
+
* instance. The index specifies the offset of the component to find. If no matching
|
|
688
|
+
* component is found at that index, an error is thrown.
|
|
689
|
+
* @param query A query for a harness to create
|
|
690
|
+
* @param index The zero-indexed offset of the component to find
|
|
691
|
+
* @return An instance of the given harness type
|
|
692
|
+
* @throws If a matching component instance can't be found.
|
|
693
|
+
*/
|
|
694
|
+
async getHarnessAtIndex(query, offset) {
|
|
695
|
+
if (offset < 0) {
|
|
696
|
+
throw Error('Index must not be negative');
|
|
697
|
+
}
|
|
698
|
+
const harnesses = await this.locatorForAll(query)();
|
|
699
|
+
if (offset >= harnesses.length) {
|
|
700
|
+
throw Error(`No harness was located at index ${offset}`);
|
|
701
|
+
}
|
|
702
|
+
return harnesses[offset];
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Searches for all instances of the component corresponding to the given harness type under the
|
|
706
|
+
* `HarnessEnvironment`'s root element, and returns a list `ComponentHarness` for each instance.
|
|
707
|
+
* @param query A query for a harness to create
|
|
708
|
+
* @return A list instances of the given harness type.
|
|
709
|
+
*/
|
|
710
|
+
getAllHarnesses(query) {
|
|
711
|
+
return this.locatorForAll(query)();
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Searches for all instance of the component corresponding to the given harness type under the
|
|
715
|
+
* `HarnessEnvironment`'s root element, and returns the number that were found.
|
|
716
|
+
* @param query A query for a harness to create
|
|
717
|
+
* @return The number of instances that were found.
|
|
718
|
+
*/
|
|
719
|
+
async countHarnesses(query) {
|
|
720
|
+
return (await this.locatorForAll(query)()).length;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Searches for an instance of the component corresponding to the given harness type under the
|
|
724
|
+
* `HarnessEnvironment`'s root element, and returns a boolean indicating if any were found.
|
|
725
|
+
* @param query A query for a harness to create
|
|
726
|
+
* @return A boolean indicating if an instance was found.
|
|
727
|
+
*/
|
|
728
|
+
async hasHarness(query) {
|
|
729
|
+
return (await this.locatorForOptional(query)()) !== null;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Searches for an element with the given selector under the evironment's root element,
|
|
733
|
+
* and returns a `HarnessLoader` rooted at the matching element. If multiple elements match the
|
|
734
|
+
* selector, the first is used. If no elements match, an error is thrown.
|
|
735
|
+
* @param selector The selector for the root element of the new `HarnessLoader`
|
|
736
|
+
* @return A `HarnessLoader` rooted at the element matching the given selector.
|
|
737
|
+
* @throws If a matching element can't be found.
|
|
738
|
+
*/
|
|
739
|
+
async getChildLoader(selector) {
|
|
740
|
+
return this.createEnvironment(await _assertResultFound(this.getAllRawElements(selector), [
|
|
741
|
+
_getDescriptionForHarnessLoaderQuery(selector),
|
|
742
|
+
]));
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Searches for all elements with the given selector under the environment's root element,
|
|
746
|
+
* and returns an array of `HarnessLoader`s, one for each matching element, rooted at that
|
|
747
|
+
* element.
|
|
748
|
+
* @param selector The selector for the root element of the new `HarnessLoader`
|
|
749
|
+
* @return A list of `HarnessLoader`s, one for each matching element, rooted at that element.
|
|
750
|
+
*/
|
|
751
|
+
async getAllChildLoaders(selector) {
|
|
752
|
+
return (await this.getAllRawElements(selector)).map(e => this.createEnvironment(e));
|
|
753
|
+
}
|
|
754
|
+
/** Creates a `ComponentHarness` for the given harness type with the given raw host element. */
|
|
755
|
+
createComponentHarness(harnessType, element) {
|
|
756
|
+
return new harnessType(this.createEnvironment(element));
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Matches the given raw elements with the given list of element and harness queries to produce a
|
|
760
|
+
* list of matched harnesses and test elements.
|
|
761
|
+
*/
|
|
762
|
+
async _getAllHarnessesAndTestElements(queries) {
|
|
763
|
+
if (!queries.length) {
|
|
764
|
+
throw Error('CDK Component harness query must contain at least one element.');
|
|
765
|
+
}
|
|
766
|
+
const { allQueries, harnessQueries, elementQueries, harnessTypes } = _parseQueries(queries);
|
|
767
|
+
// Combine all of the queries into one large comma-delimited selector and use it to get all raw
|
|
768
|
+
// elements matching any of the individual queries.
|
|
769
|
+
const rawElements = await this.getAllRawElements([...elementQueries, ...harnessQueries.map(predicate => predicate.getSelector())].join(','));
|
|
770
|
+
// If every query is searching for the same harness subclass, we know every result corresponds
|
|
771
|
+
// to an instance of that subclass. Likewise, if every query is for a `TestElement`, we know
|
|
772
|
+
// every result corresponds to a `TestElement`. Otherwise we need to verify which result was
|
|
773
|
+
// found by which selector so it can be matched to the appropriate instance.
|
|
774
|
+
const skipSelectorCheck = (elementQueries.length === 0 && harnessTypes.size === 1) || harnessQueries.length === 0;
|
|
775
|
+
const perElementMatches = await parallel(() => rawElements.map(async (rawElement) => {
|
|
776
|
+
const testElement = this.createTestElement(rawElement);
|
|
777
|
+
const allResultsForElement = await parallel(
|
|
778
|
+
// For each query, get `null` if it doesn't match, or a `TestElement` or
|
|
779
|
+
// `ComponentHarness` as appropriate if it does match. This gives us everything that
|
|
780
|
+
// matches the current raw element, but it may contain duplicate entries (e.g.
|
|
781
|
+
// multiple `TestElement` or multiple `ComponentHarness` of the same type).
|
|
782
|
+
() => allQueries.map(query => this._getQueryResultForElement(query, rawElement, testElement, skipSelectorCheck)));
|
|
783
|
+
return _removeDuplicateQueryResults(allResultsForElement);
|
|
784
|
+
}));
|
|
785
|
+
return [].concat(...perElementMatches);
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Check whether the given query matches the given element, if it does return the matched
|
|
789
|
+
* `TestElement` or `ComponentHarness`, if it does not, return null. In cases where the caller
|
|
790
|
+
* knows for sure that the query matches the element's selector, `skipSelectorCheck` can be used
|
|
791
|
+
* to skip verification and optimize performance.
|
|
792
|
+
*/
|
|
793
|
+
async _getQueryResultForElement(query, rawElement, testElement, skipSelectorCheck = false) {
|
|
794
|
+
if (typeof query === 'string') {
|
|
795
|
+
return skipSelectorCheck || (await testElement.matchesSelector(query)) ? testElement : null;
|
|
796
|
+
}
|
|
797
|
+
if (skipSelectorCheck || (await testElement.matchesSelector(query.getSelector()))) {
|
|
798
|
+
const harness = this.createComponentHarness(query.harnessType, rawElement);
|
|
799
|
+
return (await query.evaluate(harness)) ? harness : null;
|
|
800
|
+
}
|
|
801
|
+
return null;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Parses a list of queries in the format accepted by the `locatorFor*` methods into an easier to
|
|
806
|
+
* work with format.
|
|
807
|
+
*/
|
|
808
|
+
function _parseQueries(queries) {
|
|
809
|
+
const allQueries = [];
|
|
810
|
+
const harnessQueries = [];
|
|
811
|
+
const elementQueries = [];
|
|
812
|
+
const harnessTypes = new Set();
|
|
813
|
+
for (const query of queries) {
|
|
814
|
+
if (typeof query === 'string') {
|
|
815
|
+
allQueries.push(query);
|
|
816
|
+
elementQueries.push(query);
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
const predicate = query instanceof HarnessPredicate ? query : new HarnessPredicate(query, {});
|
|
820
|
+
allQueries.push(predicate);
|
|
821
|
+
harnessQueries.push(predicate);
|
|
822
|
+
harnessTypes.add(predicate.harnessType);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return { allQueries, harnessQueries, elementQueries, harnessTypes };
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Removes duplicate query results for a particular element. (e.g. multiple `TestElement`
|
|
829
|
+
* instances or multiple instances of the same `ComponentHarness` class.
|
|
830
|
+
*/
|
|
831
|
+
async function _removeDuplicateQueryResults(results) {
|
|
832
|
+
let testElementMatched = false;
|
|
833
|
+
let matchedHarnessTypes = new Set();
|
|
834
|
+
const dedupedMatches = [];
|
|
835
|
+
for (const result of results) {
|
|
836
|
+
if (!result) {
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
if (result instanceof ComponentHarness) {
|
|
840
|
+
if (!matchedHarnessTypes.has(result.constructor)) {
|
|
841
|
+
matchedHarnessTypes.add(result.constructor);
|
|
842
|
+
dedupedMatches.push(result);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
else if (!testElementMatched) {
|
|
846
|
+
testElementMatched = true;
|
|
847
|
+
dedupedMatches.push(result);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return dedupedMatches;
|
|
851
|
+
}
|
|
852
|
+
/** Verifies that there is at least one result in an array. */
|
|
853
|
+
async function _assertResultFound(results, queryDescriptions) {
|
|
854
|
+
const result = (await results)[0];
|
|
855
|
+
if (result == undefined) {
|
|
856
|
+
throw Error(`Failed to find element matching one of the following queries:\n` +
|
|
857
|
+
queryDescriptions.map(desc => `(${desc})`).join(',\n'));
|
|
858
|
+
}
|
|
859
|
+
return result;
|
|
860
|
+
}
|
|
861
|
+
/** Gets a list of description strings from a list of queries. */
|
|
862
|
+
function _getDescriptionForLocatorForQueries(queries) {
|
|
863
|
+
return queries.map(query => typeof query === 'string'
|
|
864
|
+
? _getDescriptionForTestElementQuery(query)
|
|
865
|
+
: _getDescriptionForComponentHarnessQuery(query));
|
|
866
|
+
}
|
|
867
|
+
/** Gets a description string for a `ComponentHarness` query. */
|
|
868
|
+
function _getDescriptionForComponentHarnessQuery(query) {
|
|
869
|
+
const harnessPredicate = query instanceof HarnessPredicate ? query : new HarnessPredicate(query, {});
|
|
870
|
+
const { name, hostSelector } = harnessPredicate.harnessType;
|
|
871
|
+
const description = `${name} with host element matching selector: "${hostSelector}"`;
|
|
872
|
+
const constraints = harnessPredicate.getDescription();
|
|
873
|
+
return (description +
|
|
874
|
+
(constraints ? ` satisfying the constraints: ${harnessPredicate.getDescription()}` : ''));
|
|
875
|
+
}
|
|
876
|
+
/** Gets a description string for a `TestElement` query. */
|
|
877
|
+
function _getDescriptionForTestElementQuery(selector) {
|
|
878
|
+
return `TestElement for element matching selector: "${selector}"`;
|
|
879
|
+
}
|
|
880
|
+
/** Gets a description string for a `HarnessLoader` query. */
|
|
881
|
+
function _getDescriptionForHarnessLoaderQuery(selector) {
|
|
882
|
+
return `HarnessLoader for element matching selector: "${selector}"`;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** An enum of non-text keys that can be used with the `sendKeys` method. */
|
|
886
|
+
// NOTE: This is a separate enum from `@kato-lee/cdk/keycodes` because we don't necessarily want to
|
|
887
|
+
// support every possible keyCode. We also can't rely on Protractor's `Key` because we don't want a
|
|
888
|
+
// dependency on any particular testing framework here. Instead we'll just maintain this supported
|
|
889
|
+
// list of keys and let individual concrete `HarnessEnvironment` classes map them to whatever key
|
|
890
|
+
// representation is used in its respective testing framework.
|
|
891
|
+
// tslint:disable-next-line:prefer-const-enum Seems like this causes some issues with System.js
|
|
892
|
+
var TestKey;
|
|
893
|
+
(function (TestKey) {
|
|
894
|
+
TestKey[TestKey["BACKSPACE"] = 0] = "BACKSPACE";
|
|
895
|
+
TestKey[TestKey["TAB"] = 1] = "TAB";
|
|
896
|
+
TestKey[TestKey["ENTER"] = 2] = "ENTER";
|
|
897
|
+
TestKey[TestKey["SHIFT"] = 3] = "SHIFT";
|
|
898
|
+
TestKey[TestKey["CONTROL"] = 4] = "CONTROL";
|
|
899
|
+
TestKey[TestKey["ALT"] = 5] = "ALT";
|
|
900
|
+
TestKey[TestKey["ESCAPE"] = 6] = "ESCAPE";
|
|
901
|
+
TestKey[TestKey["PAGE_UP"] = 7] = "PAGE_UP";
|
|
902
|
+
TestKey[TestKey["PAGE_DOWN"] = 8] = "PAGE_DOWN";
|
|
903
|
+
TestKey[TestKey["END"] = 9] = "END";
|
|
904
|
+
TestKey[TestKey["HOME"] = 10] = "HOME";
|
|
905
|
+
TestKey[TestKey["LEFT_ARROW"] = 11] = "LEFT_ARROW";
|
|
906
|
+
TestKey[TestKey["UP_ARROW"] = 12] = "UP_ARROW";
|
|
907
|
+
TestKey[TestKey["RIGHT_ARROW"] = 13] = "RIGHT_ARROW";
|
|
908
|
+
TestKey[TestKey["DOWN_ARROW"] = 14] = "DOWN_ARROW";
|
|
909
|
+
TestKey[TestKey["INSERT"] = 15] = "INSERT";
|
|
910
|
+
TestKey[TestKey["DELETE"] = 16] = "DELETE";
|
|
911
|
+
TestKey[TestKey["F1"] = 17] = "F1";
|
|
912
|
+
TestKey[TestKey["F2"] = 18] = "F2";
|
|
913
|
+
TestKey[TestKey["F3"] = 19] = "F3";
|
|
914
|
+
TestKey[TestKey["F4"] = 20] = "F4";
|
|
915
|
+
TestKey[TestKey["F5"] = 21] = "F5";
|
|
916
|
+
TestKey[TestKey["F6"] = 22] = "F6";
|
|
917
|
+
TestKey[TestKey["F7"] = 23] = "F7";
|
|
918
|
+
TestKey[TestKey["F8"] = 24] = "F8";
|
|
919
|
+
TestKey[TestKey["F9"] = 25] = "F9";
|
|
920
|
+
TestKey[TestKey["F10"] = 26] = "F10";
|
|
921
|
+
TestKey[TestKey["F11"] = 27] = "F11";
|
|
922
|
+
TestKey[TestKey["F12"] = 28] = "F12";
|
|
923
|
+
TestKey[TestKey["META"] = 29] = "META";
|
|
924
|
+
TestKey[TestKey["COMMA"] = 30] = "COMMA";
|
|
925
|
+
})(TestKey || (TestKey = {}));
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Returns an error which reports that no keys have been specified.
|
|
929
|
+
* @docs-private
|
|
930
|
+
*/
|
|
931
|
+
function getNoKeysSpecifiedError() {
|
|
932
|
+
return Error('No keys have been specified.');
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Gets text of element excluding certain selectors within the element.
|
|
937
|
+
* @param element Element to get text from,
|
|
938
|
+
* @param excludeSelector Selector identifying which elements to exclude,
|
|
939
|
+
*/
|
|
940
|
+
function _getTextWithExcludedElements(element, excludeSelector) {
|
|
941
|
+
const clone = element.cloneNode(true);
|
|
942
|
+
const exclusions = clone.querySelectorAll(excludeSelector);
|
|
943
|
+
for (let i = 0; i < exclusions.length; i++) {
|
|
944
|
+
exclusions[i].remove();
|
|
945
|
+
}
|
|
946
|
+
return (clone.textContent || '').trim();
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
export { ComponentHarness, ContentContainerComponentHarness, HarnessEnvironment, HarnessPredicate, TestKey, _getTextWithExcludedElements, getNoKeysSpecifiedError, handleAutoChangeDetectionStatus, manualChangeDetection, parallel, stopHandlingAutoChangeDetectionStatus };
|
|
950
|
+
//# sourceMappingURL=testing.mjs.map
|