@angular-wave/angular.ts 0.9.4 → 0.9.6
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/@types/index.d.ts +1 -84
- package/{src/index.ts → @types/namespace.d.ts} +4 -24
- package/@types/router/template-factory.d.ts +2 -2
- package/dist/angular-ts.esm.js +3 -3
- package/dist/angular-ts.umd.js +3 -3
- package/dist/angular-ts.umd.min.js +1 -1
- package/package.json +9 -2
- package/.github/workflows/ci.yml +0 -104
- package/.github/workflows/gh-pages.yml +0 -75
- package/.husky/pre-commit +0 -5
- package/.prettierignore +0 -9
- package/CHANGELOG.md +0 -17667
- package/CODE_OF_CONDUCT.md +0 -3
- package/CONTRIBUTING.md +0 -247
- package/DEVELOPERS.md +0 -499
- package/Makefile +0 -60
- package/RELEASE.md +0 -86
- package/TRIAGING.md +0 -127
- package/docs/.cspell.yml +0 -8
- package/docs/.github/dependabot.yml +0 -14
- package/docs/.nvmrc +0 -1
- package/docs/CONTRIBUTING.md +0 -28
- package/docs/Dockerfile +0 -4
- package/docs/LICENSE +0 -201
- package/docs/README.md +0 -217
- package/docs/assets/icons/logo.svg +0 -1
- package/docs/assets/scss/_variables_project.scss +0 -12
- package/docs/assets/scss/_variables_project_after_bs.scss +0 -8
- package/docs/assets/scss/index.scss +0 -48
- package/docs/config.yaml +0 -15
- package/docs/content/_index.md +0 -28
- package/docs/content/docs/_index.md +0 -61
- package/docs/content/docs/directive/_index.md +0 -4
- package/docs/content/docs/directive/app.md +0 -11
- package/docs/content/docs/directive/aria.md +0 -0
- package/docs/content/docs/directive/bind.md +0 -72
- package/docs/content/docs/directive/blur.md +0 -38
- package/docs/content/docs/directive/channel.md +0 -37
- package/docs/content/docs/directive/class-even.md +0 -47
- package/docs/content/docs/directive/class-odd.md +0 -48
- package/docs/content/docs/directive/class.md +0 -64
- package/docs/content/docs/directive/click.md +0 -41
- package/docs/content/docs/directive/cloak.md +0 -74
- package/docs/content/docs/directive/copy.md +0 -38
- package/docs/content/docs/directive/cut.md +0 -40
- package/docs/content/docs/directive/dblclick.md +0 -41
- package/docs/content/docs/directive/focus.md +0 -38
- package/docs/content/docs/directive/get.md +0 -203
- package/docs/content/docs/directive/include.md +0 -7
- package/docs/content/docs/directive/keydown.md +0 -38
- package/docs/content/docs/directive/keyup.md +0 -38
- package/docs/content/docs/directive/load.md +0 -43
- package/docs/content/docs/directive/mousedown.md +0 -38
- package/docs/content/docs/directive/mouseenter.md +0 -38
- package/docs/content/docs/directive/mouseleave.md +0 -38
- package/docs/content/docs/directive/mousemove.md +0 -38
- package/docs/content/docs/directive/mouseout.md +0 -38
- package/docs/content/docs/directive/mouseover.md +0 -38
- package/docs/content/docs/directive/mouseup.md +0 -38
- package/docs/content/docs/directive/non-bindable.md +0 -28
- package/docs/content/docs/filter/_index.md +0 -4
- package/docs/content/docs/filter/filter.md +0 -78
- package/docs/content/docs/filter/json.md +0 -19
- package/docs/content/docs/filter/limit-to.md +0 -30
- package/docs/content/docs/filter/order-by.md +0 -123
- package/docs/content/docs/provider/_index.md +0 -4
- package/docs/content/docs/provider/eventBusProvider.md +0 -35
- package/docs/content/docs/provider/locationProvider.md +0 -26
- package/docs/content/docs/provider/logProvider.md +0 -59
- package/docs/content/docs/provider/sceProvider.md +0 -194
- package/docs/content/docs/provider/templateCacheProvider.md +0 -100
- package/docs/content/docs/provider/templateRequestProvider.md +0 -5
- package/docs/content/docs/service/_index.md +0 -4
- package/docs/content/docs/service/compile.md +0 -5
- package/docs/content/docs/service/controller.md +0 -5
- package/docs/content/docs/service/eventBus.md +0 -56
- package/docs/content/docs/service/http.md +0 -161
- package/docs/content/docs/service/interpolation.md +0 -5
- package/docs/content/docs/service/location.md +0 -57
- package/docs/content/docs/service/log.md +0 -113
- package/docs/content/docs/service/parse.md +0 -5
- package/docs/content/docs/service/rootElement.md +0 -5
- package/docs/content/docs/service/rootScope.md +0 -5
- package/docs/content/docs/service/sce.md +0 -194
- package/docs/content/docs/service/templateCache.md +0 -64
- package/docs/content/docs/service/templateRequest.md +0 -5
- package/docs/content/docs/service/url.md +0 -5
- package/docs/content/docs/values/_index.md +0 -4
- package/docs/content/docs/values/document.md +0 -29
- package/docs/content/docs/values/window.md +0 -29
- package/docs/docker-compose.yaml +0 -12
- package/docs/docsy.work +0 -5
- package/docs/docsy.work.sum +0 -0
- package/docs/go.mod +0 -5
- package/docs/go.sum +0 -6
- package/docs/hugo-disabled.toml +0 -220
- package/docs/hugo.yaml +0 -200
- package/docs/layouts/404.html +0 -13
- package/docs/layouts/_markup/render-heading.html +0 -1
- package/docs/layouts/partials/hooks/head-end.html +0 -3
- package/docs/layouts/shortcodes/showcss.html +0 -2
- package/docs/layouts/shortcodes/showhtml.html +0 -2
- package/docs/layouts/shortcodes/showjs.html +0 -2
- package/docs/layouts/shortcodes/showraw.html +0 -1
- package/docs/layouts/shortcodes/version.html +0 -1
- package/docs/package-lock.json +0 -2293
- package/docs/package.json +0 -53
- package/docs/static/examples/counter/counter-test.html +0 -13
- package/docs/static/examples/counter/counter.html +0 -5
- package/docs/static/examples/counter/counter.test.js +0 -28
- package/docs/static/examples/document/document.html +0 -3
- package/docs/static/examples/eventbus/eventbus-test.html +0 -15
- package/docs/static/examples/eventbus/eventbus.html +0 -13
- package/docs/static/examples/eventbus/eventbus.js +0 -15
- package/docs/static/examples/eventbus/eventbus.test.js +0 -19
- package/docs/static/examples/i18n/i18n.html +0 -77
- package/docs/static/examples/ng-bind/ng-bind.html +0 -9
- package/docs/static/examples/ng-blur/ng-blur.html +0 -9
- package/docs/static/examples/ng-channel/ng-channel-test.html +0 -17
- package/docs/static/examples/ng-channel/ng-channel.html +0 -24
- package/docs/static/examples/ng-channel/ng-channel.test.js +0 -31
- package/docs/static/examples/ng-class/ng-class.html +0 -71
- package/docs/static/examples/ng-class-even/ng-class-even.html +0 -8
- package/docs/static/examples/ng-class-odd/ng-class-odd.html +0 -8
- package/docs/static/examples/ng-click/ng-click.html +0 -6
- package/docs/static/examples/ng-copy/ng-copy.html +0 -6
- package/docs/static/examples/ng-cut/ng-cut.html +0 -6
- package/docs/static/examples/ng-dblclick/ng-dblclick.html +0 -10
- package/docs/static/examples/ng-focus/ng-focus.html +0 -9
- package/docs/static/examples/ng-keydown/ng-keydown.html +0 -9
- package/docs/static/examples/ng-keyup/ng-keyup.html +0 -9
- package/docs/static/examples/ng-load/ng-load.html +0 -8
- package/docs/static/examples/ng-mousedown/ng-mousedown.html +0 -6
- package/docs/static/examples/ng-mouseenter/ng-mouseenter.html +0 -4
- package/docs/static/examples/ng-mouseleave/ng-mouseleave.html +0 -4
- package/docs/static/examples/ng-mousemove/ng-mousemove.html +0 -4
- package/docs/static/examples/ng-mouseout/ng-mouseout.html +0 -4
- package/docs/static/examples/ng-mouseover/ng-mouseover.html +0 -4
- package/docs/static/examples/ng-mouseup/ng-mouseup.html +0 -4
- package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +0 -13
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +0 -3
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +0 -11
- package/docs/static/examples/window/window.html +0 -4
- package/docs/static/typedoc/.nojekyll +0 -1
- package/docs/static/typedoc/assets/hierarchy.js +0 -1
- package/docs/static/typedoc/assets/highlight.css +0 -29
- package/docs/static/typedoc/assets/icons.js +0 -18
- package/docs/static/typedoc/assets/icons.svg +0 -1
- package/docs/static/typedoc/assets/main.js +0 -60
- package/docs/static/typedoc/assets/navigation.js +0 -1
- package/docs/static/typedoc/assets/search.js +0 -1
- package/docs/static/typedoc/assets/style.css +0 -1633
- package/docs/static/typedoc/classes/Location.html +0 -55
- package/docs/static/typedoc/classes/LocationProvider.html +0 -20
- package/docs/static/typedoc/classes/LogProvider.html +0 -6
- package/docs/static/typedoc/classes/PubSub.html +0 -71
- package/docs/static/typedoc/classes/PubSubProvider.html +0 -4
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +0 -5
- package/docs/static/typedoc/hierarchy.html +0 -1
- package/docs/static/typedoc/index.html +0 -1
- package/docs/static/typedoc/interfaces/DefaultPorts.html +0 -5
- package/docs/static/typedoc/interfaces/Html5Mode.html +0 -23
- package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +0 -1
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +0 -31
- package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +0 -6
- package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +0 -1
- package/docs/static/typedoc/interfaces/HttpResponse.html +0 -7
- package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +0 -1
- package/docs/static/typedoc/interfaces/HttpService.html +0 -38
- package/docs/static/typedoc/interfaces/LogService.html +0 -12
- package/docs/static/typedoc/interfaces/RequestConfig.html +0 -48
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +0 -38
- package/docs/static/typedoc/interfaces/ServiceProvider.html +0 -5
- package/docs/static/typedoc/interfaces/UrlParts.html +0 -9
- package/docs/static/typedoc/types/HttpParamSerializer.html +0 -2
- package/docs/static/typedoc/types/HttpParams.html +0 -2
- package/docs/static/typedoc/types/HttpPromise.html +0 -1
- package/docs/static/typedoc/types/HttpResponseStatus.html +0 -1
- package/docs/static/typedoc/types/LogCall.html +0 -2
- package/docs/static/typedoc/types/LogServiceFactory.html +0 -2
- package/docs/static/typedoc/types/UrlChangeListener.html +0 -5
- package/docs/static/typedoc/variables/EventBus.html +0 -1
- package/docs/static/version.js +0 -13
- package/docs/test-results/.last-run.json +0 -4
- package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +0 -50
- package/eslint.config.js +0 -26
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +0 -19
- package/index.html +0 -86
- package/legacy.d.ts +0 -1678
- package/playwright.config.ts +0 -81
- package/public/jasmine/boot0.js +0 -66
- package/public/jasmine/boot1.js +0 -134
- package/public/jasmine/jasmine-html.js +0 -970
- package/public/jasmine/jasmine.css +0 -323
- package/public/jasmine/jasmine.js +0 -11406
- package/public/public/README.md +0 -1
- package/public/public/circle.html +0 -1
- package/public/public/jasmine-helper.css +0 -9
- package/public/public/my_child_directive.html +0 -1
- package/public/public/my_directive.html +0 -1
- package/public/public/my_other_directive.html +0 -1
- package/public/public/test.html +0 -1
- package/rollup.config.js +0 -51
- package/src/angular.js +0 -286
- package/src/angular.spec.js +0 -1191
- package/src/animations/animate-cache.js +0 -80
- package/src/animations/animate-children-directive.js +0 -32
- package/src/animations/animate-children-directive.md +0 -80
- package/src/animations/animate-css-driver.js +0 -284
- package/src/animations/animate-css.html +0 -58
- package/src/animations/animate-css.js +0 -915
- package/src/animations/animate-css.md +0 -263
- package/src/animations/animate-js-driver.js +0 -60
- package/src/animations/animate-js.html +0 -47
- package/src/animations/animate-js.js +0 -371
- package/src/animations/animate-queue.js +0 -859
- package/src/animations/animate-runner.js +0 -193
- package/src/animations/animate-swap.js +0 -33
- package/src/animations/animate-swap.md +0 -88
- package/src/animations/animate.html +0 -19
- package/src/animations/animate.js +0 -546
- package/src/animations/animate.md +0 -933
- package/src/animations/animate.spec.js +0 -490
- package/src/animations/animation.js +0 -519
- package/src/animations/animations.test.js +0 -10
- package/src/animations/interface.ts +0 -19
- package/src/animations/raf-scheduler.html +0 -19
- package/src/animations/raf-scheduler.js +0 -92
- package/src/animations/raf-scheduler.spec.js +0 -98
- package/src/animations/shared.js +0 -341
- package/src/binding.html +0 -19
- package/src/binding.spec.js +0 -474
- package/src/binding.test.js +0 -10
- package/src/core/compile/attributes.js +0 -337
- package/src/core/compile/compile.html +0 -19
- package/src/core/compile/compile.js +0 -3271
- package/src/core/compile/compile.md +0 -1128
- package/src/core/compile/compile.spec.js +0 -15574
- package/src/core/compile/compile.test.js +0 -12
- package/src/core/controller/controller.html +0 -22
- package/src/core/controller/controller.js +0 -193
- package/src/core/controller/controller.spec.js +0 -334
- package/src/core/controller/controller.test.js +0 -12
- package/src/core/controller/interface.ts +0 -6
- package/src/core/core.html +0 -20
- package/src/core/core.test.js +0 -12
- package/src/core/di/injector.html +0 -19
- package/src/core/di/injector.js +0 -307
- package/src/core/di/injector.md +0 -740
- package/src/core/di/injector.spec.js +0 -2310
- package/src/core/di/injector.test.js +0 -12
- package/src/core/di/internal-injector.js +0 -286
- package/src/core/di/ng-module.html +0 -19
- package/src/core/di/ng-module.js +0 -229
- package/src/core/di/ng-module.spec.js +0 -263
- package/src/core/di/ng-module.test.js +0 -12
- package/src/core/filter/filter.html +0 -19
- package/src/core/filter/filter.js +0 -55
- package/src/core/filter/filter.md +0 -132
- package/src/core/filter/filter.spec.js +0 -149
- package/src/core/filter/filter.test.js +0 -12
- package/src/core/interpolate/interface.ts +0 -14
- package/src/core/interpolate/interpolate.html +0 -22
- package/src/core/interpolate/interpolate.js +0 -410
- package/src/core/interpolate/interpolate.spec.js +0 -601
- package/src/core/interpolate/interpolate.test.js +0 -12
- package/src/core/parse/ast/ast-node.ts +0 -81
- package/src/core/parse/ast/ast.html +0 -19
- package/src/core/parse/ast/ast.js +0 -574
- package/src/core/parse/ast/ast.spec.js +0 -1453
- package/src/core/parse/ast/ast.test.js +0 -10
- package/src/core/parse/ast-type.js +0 -23
- package/src/core/parse/interface.ts +0 -84
- package/src/core/parse/interpreter.js +0 -915
- package/src/core/parse/lexer/lexer.html +0 -19
- package/src/core/parse/lexer/lexer.js +0 -338
- package/src/core/parse/lexer/lexer.spec.js +0 -303
- package/src/core/parse/lexer/lexer.test.js +0 -10
- package/src/core/parse/lexer/token.ts +0 -22
- package/src/core/parse/parse.html +0 -19
- package/src/core/parse/parse.js +0 -337
- package/src/core/parse/parse.md +0 -57
- package/src/core/parse/parse.spec.js +0 -2107
- package/src/core/parse/parse.test.js +0 -10
- package/src/core/parse/parser/parser.html +0 -19
- package/src/core/parse/parser/parser.js +0 -64
- package/src/core/parse/parser/parser.spec.js +0 -8
- package/src/core/parse/parser/parser.test.js +0 -10
- package/src/core/prop.spec.js +0 -775
- package/src/core/root-element.spec.js +0 -14
- package/src/core/sanitize/interface.ts +0 -10
- package/src/core/sanitize/sanitize-uri.js +0 -75
- package/src/core/sanitize/sanitize-uri.spec.js +0 -249
- package/src/core/sanitize/sanitize-uri.test.js +0 -12
- package/src/core/sanitize/sanitize.html +0 -22
- package/src/core/scope/scope.html +0 -19
- package/src/core/scope/scope.js +0 -1252
- package/src/core/scope/scope.spec.js +0 -3000
- package/src/core/scope/scope.test.js +0 -12
- package/src/directive/aria/aria.html +0 -19
- package/src/directive/aria/aria.js +0 -382
- package/src/directive/aria/aria.md +0 -145
- package/src/directive/aria/aria.spec.js +0 -1241
- package/src/directive/aria/aria.test.js +0 -12
- package/src/directive/attrs/attrs.html +0 -19
- package/src/directive/attrs/attrs.js +0 -106
- package/src/directive/attrs/attrs.md +0 -224
- package/src/directive/attrs/attrs.spec.js +0 -71
- package/src/directive/attrs/attrs.test.js +0 -12
- package/src/directive/attrs/boolean.html +0 -19
- package/src/directive/attrs/boolean.spec.js +0 -137
- package/src/directive/attrs/boolean.test.js +0 -12
- package/src/directive/attrs/element-style.html +0 -22
- package/src/directive/attrs/element-style.spec.js +0 -85
- package/src/directive/attrs/element-style.test.js +0 -12
- package/src/directive/attrs/src.html +0 -19
- package/src/directive/attrs/src.spec.js +0 -163
- package/src/directive/attrs/src.test.js +0 -12
- package/src/directive/bind/bind-html.spec.js +0 -36
- package/src/directive/bind/bind.html +0 -20
- package/src/directive/bind/bind.js +0 -78
- package/src/directive/bind/bind.md +0 -142
- package/src/directive/bind/bind.spec.js +0 -314
- package/src/directive/bind/bind.test.js +0 -12
- package/src/directive/channel/channel.html +0 -19
- package/src/directive/channel/channel.js +0 -30
- package/src/directive/channel/channel.spec.js +0 -67
- package/src/directive/channel/channel.test.js +0 -10
- package/src/directive/class/class-test.html +0 -23
- package/src/directive/class/class.html +0 -19
- package/src/directive/class/class.js +0 -184
- package/src/directive/class/class.spec.js +0 -704
- package/src/directive/class/class.test.js +0 -12
- package/src/directive/cloak/cloak.html +0 -19
- package/src/directive/cloak/cloak.js +0 -11
- package/src/directive/cloak/cloak.spec.js +0 -44
- package/src/directive/cloak/cloak.test.js +0 -12
- package/src/directive/controller/controller.html +0 -22
- package/src/directive/controller/controller.js +0 -11
- package/src/directive/controller/controller.md +0 -46
- package/src/directive/controller/controller.spec.js +0 -175
- package/src/directive/controller/controller.test.js +0 -12
- package/src/directive/events/click.spec.js +0 -35
- package/src/directive/events/event.spec.js +0 -267
- package/src/directive/events/events-test.html +0 -36
- package/src/directive/events/events.html +0 -20
- package/src/directive/events/events.js +0 -65
- package/src/directive/events/events.md +0 -125
- package/src/directive/events/events.test.js +0 -12
- package/src/directive/form/form.html +0 -19
- package/src/directive/form/form.js +0 -669
- package/src/directive/form/form.spec.js +0 -1515
- package/src/directive/form/form.test.js +0 -12
- package/src/directive/http/delete.spec.js +0 -23
- package/src/directive/http/form-router-test.html +0 -44
- package/src/directive/http/form-test.html +0 -18
- package/src/directive/http/get.spec.js +0 -488
- package/src/directive/http/http.html +0 -22
- package/src/directive/http/http.js +0 -342
- package/src/directive/http/http.test.js +0 -12
- package/src/directive/http/interface.ts +0 -36
- package/src/directive/http/post-example.html +0 -30
- package/src/directive/http/post.spec.js +0 -521
- package/src/directive/http/put.spec.js +0 -23
- package/src/directive/if/if-animate-css.html +0 -57
- package/src/directive/if/if-animate-svg.html +0 -25
- package/src/directive/if/if.html +0 -19
- package/src/directive/if/if.js +0 -72
- package/src/directive/if/if.md +0 -76
- package/src/directive/if/if.spec.js +0 -293
- package/src/directive/if/if.test.js +0 -114
- package/src/directive/include/include.html +0 -19
- package/src/directive/include/include.js +0 -151
- package/src/directive/include/include.md +0 -87
- package/src/directive/include/include.spec.js +0 -734
- package/src/directive/include/include.test.js +0 -12
- package/src/directive/init/init.html +0 -19
- package/src/directive/init/init.js +0 -22
- package/src/directive/init/init.md +0 -41
- package/src/directive/init/init.spec.js +0 -68
- package/src/directive/init/init.test.js +0 -12
- package/src/directive/inject/inject.html +0 -19
- package/src/directive/inject/inject.js +0 -35
- package/src/directive/inject/inject.spec.js +0 -108
- package/src/directive/inject/inject.test.js +0 -12
- package/src/directive/input/input-example.html +0 -15
- package/src/directive/input/input.html +0 -19
- package/src/directive/input/input.js +0 -1078
- package/src/directive/input/input.md +0 -706
- package/src/directive/input/input.spec.js +0 -3700
- package/src/directive/input/input.test.js +0 -12
- package/src/directive/messages/messages.html +0 -22
- package/src/directive/messages/messages.js +0 -349
- package/src/directive/messages/messages.md +0 -543
- package/src/directive/messages/messages.spec.js +0 -1083
- package/src/directive/messages/messages.test.js +0 -12
- package/src/directive/model/change.md +0 -25
- package/src/directive/model/model.html +0 -19
- package/src/directive/model/model.js +0 -1170
- package/src/directive/model/model.spec.js +0 -1976
- package/src/directive/model/model.test.js +0 -12
- package/src/directive/model-options/model-option.test.js +0 -12
- package/src/directive/model-options/model-options.html +0 -22
- package/src/directive/model-options/model-options.js +0 -142
- package/src/directive/model-options/model-options.md +0 -407
- package/src/directive/model-options/model-options.spec.js +0 -1022
- package/src/directive/non-bindable/non-bindable.html +0 -22
- package/src/directive/non-bindable/non-bindable.js +0 -9
- package/src/directive/non-bindable/non-bindable.spec.js +0 -59
- package/src/directive/non-bindable/non-bindable.test.js +0 -12
- package/src/directive/observe/observe-demo.html +0 -184
- package/src/directive/observe/observe.html +0 -19
- package/src/directive/observe/observe.js +0 -41
- package/src/directive/observe/observe.spec.js +0 -106
- package/src/directive/observe/observe.test.js +0 -10
- package/src/directive/on/on.html +0 -19
- package/src/directive/on/on.spec.js +0 -215
- package/src/directive/on/on.test.js +0 -12
- package/src/directive/options/options-example.html +0 -17
- package/src/directive/options/options.html +0 -22
- package/src/directive/options/options.js +0 -542
- package/src/directive/options/options.md +0 -179
- package/src/directive/options/options.spec.js +0 -3554
- package/src/directive/options/options.test.js +0 -12
- package/src/directive/ref/href.html +0 -19
- package/src/directive/ref/href.spec.js +0 -141
- package/src/directive/ref/href.test.js +0 -19
- package/src/directive/ref/ref.html +0 -19
- package/src/directive/ref/ref.js +0 -89
- package/src/directive/ref/ref.spec.js +0 -546
- package/src/directive/repeat/repeat.html +0 -19
- package/src/directive/repeat/repeat.js +0 -333
- package/src/directive/repeat/repeat.md +0 -330
- package/src/directive/repeat/repeat.spec.js +0 -1209
- package/src/directive/repeat/repeat.test.js +0 -12
- package/src/directive/script/script.html +0 -19
- package/src/directive/script/script.js +0 -17
- package/src/directive/script/script.md +0 -11
- package/src/directive/script/script.spec.js +0 -47
- package/src/directive/script/script.test.js +0 -12
- package/src/directive/select/select.html +0 -19
- package/src/directive/select/select.js +0 -594
- package/src/directive/select/select.md +0 -74
- package/src/directive/select/select.spec.js +0 -2566
- package/src/directive/select/select.test.js +0 -12
- package/src/directive/setter/setter.html +0 -19
- package/src/directive/setter/setter.js +0 -59
- package/src/directive/setter/setter.spec.js +0 -100
- package/src/directive/setter/setter.test.js +0 -12
- package/src/directive/show-hide/show-hide.html +0 -22
- package/src/directive/show-hide/show-hide.js +0 -65
- package/src/directive/show-hide/show-hide.md +0 -255
- package/src/directive/show-hide/show-hide.spec.js +0 -268
- package/src/directive/show-hide/show-hide.test.js +0 -12
- package/src/directive/style/style.html +0 -19
- package/src/directive/style/style.js +0 -27
- package/src/directive/style/style.md +0 -23
- package/src/directive/style/style.spec.js +0 -183
- package/src/directive/style/style.test.js +0 -12
- package/src/directive/switch/switch.html +0 -19
- package/src/directive/switch/switch.js +0 -133
- package/src/directive/switch/switch.md +0 -66
- package/src/directive/switch/switch.spec.js +0 -509
- package/src/directive/switch/switch.test.js +0 -12
- package/src/directive/transclude/transclude.js +0 -122
- package/src/directive/validators/validators.html +0 -22
- package/src/directive/validators/validators.js +0 -346
- package/src/directive/validators/validators.spec.js +0 -740
- package/src/directive/validators/validators.test.js +0 -12
- package/src/filters/filter.js +0 -213
- package/src/filters/filter.spec.js +0 -719
- package/src/filters/filters.html +0 -22
- package/src/filters/filters.js +0 -239
- package/src/filters/filters.spec.js +0 -36
- package/src/filters/filters.test.js +0 -12
- package/src/filters/interface.ts +0 -9
- package/src/filters/limit-to.js +0 -55
- package/src/filters/limit-to.spec.js +0 -252
- package/src/filters/order-by.js +0 -181
- package/src/filters/order-by.spec.js +0 -883
- package/src/index.js +0 -6
- package/src/index.spec.js +0 -11
- package/src/injection-tokens.js +0 -81
- package/src/interface.ts +0 -430
- package/src/ng.js +0 -291
- package/src/ng.spec.js +0 -45
- package/src/router/common/trace.js +0 -240
- package/src/router/directives/component-example.html +0 -37
- package/src/router/directives/state-directives.html +0 -22
- package/src/router/directives/state-directives.js +0 -393
- package/src/router/directives/state-directives.md +0 -435
- package/src/router/directives/state-directives.spec.js +0 -1091
- package/src/router/directives/state-directives.test.js +0 -10
- package/src/router/directives/view-directive.js +0 -489
- package/src/router/directives/view-directive.spec.js +0 -1921
- package/src/router/directives/view-directive.test.js +0 -10
- package/src/router/directives/view-directives.html +0 -22
- package/src/router/glob/glob.html +0 -19
- package/src/router/glob/glob.js +0 -102
- package/src/router/glob/glob.spec.js +0 -108
- package/src/router/glob/glob.test.js +0 -12
- package/src/router/hooks/core-resolvables.js +0 -38
- package/src/router/hooks/ignored-transition.js +0 -25
- package/src/router/hooks/invalid-transition.js +0 -14
- package/src/router/hooks/lazy-load.js +0 -104
- package/src/router/hooks/on-enter-exit-retain.js +0 -55
- package/src/router/hooks/redirect-to.js +0 -38
- package/src/router/hooks/resolve.js +0 -57
- package/src/router/hooks/update-globals.js +0 -34
- package/src/router/hooks/url.js +0 -34
- package/src/router/hooks/views.js +0 -41
- package/src/router/params/interface.ts +0 -626
- package/src/router/params/param-factory.js +0 -23
- package/src/router/params/param-type.js +0 -133
- package/src/router/params/param-types.js +0 -153
- package/src/router/params/param.js +0 -243
- package/src/router/params/state-params.js +0 -36
- package/src/router/path/path-node.js +0 -78
- package/src/router/path/path-utils.js +0 -207
- package/src/router/resolve/interface.ts +0 -208
- package/src/router/resolve/resolvable.js +0 -123
- package/src/router/resolve/resolve-context.js +0 -190
- package/src/router/router-test-hashbang.html +0 -45
- package/src/router/router-test.html +0 -41
- package/src/router/router.html +0 -22
- package/src/router/router.js +0 -54
- package/src/router/router.test.js +0 -12
- package/src/router/services.spec.js +0 -52
- package/src/router/state/interface.ts +0 -1007
- package/src/router/state/state-builder.js +0 -376
- package/src/router/state/state-builder.spec.js +0 -86
- package/src/router/state/state-matcher.js +0 -64
- package/src/router/state/state-object.js +0 -118
- package/src/router/state/state-queue-manager.js +0 -95
- package/src/router/state/state-registry.js +0 -262
- package/src/router/state/state-service.js +0 -687
- package/src/router/state/state.html +0 -23
- package/src/router/state/state.spec.js +0 -1002
- package/src/router/state/state.test.js +0 -12
- package/src/router/state/target-state.js +0 -162
- package/src/router/state/views.js +0 -195
- package/src/router/state-filter.spec.js +0 -139
- package/src/router/state-filters.js +0 -46
- package/src/router/template-factory.html +0 -19
- package/src/router/template-factory.js +0 -249
- package/src/router/template-factory.spec.js +0 -146
- package/src/router/template-factory.test.js +0 -12
- package/src/router/transition/hook-builder.js +0 -137
- package/src/router/transition/hook-registry.js +0 -181
- package/src/router/transition/interface.js +0 -18
- package/src/router/transition/interface.ts +0 -922
- package/src/router/transition/reject-factory.js +0 -122
- package/src/router/transition/transition-event-type.js +0 -26
- package/src/router/transition/transition-hook.js +0 -199
- package/src/router/transition/transition-service.js +0 -297
- package/src/router/transition/transition.js +0 -653
- package/src/router/url/url-config.js +0 -155
- package/src/router/url/url-matcher.js +0 -532
- package/src/router/url/url-rule.js +0 -231
- package/src/router/url/url-rules.js +0 -350
- package/src/router/url/url-service.js +0 -446
- package/src/router/url/url-service.spec.js +0 -1288
- package/src/router/url/url.html +0 -19
- package/src/router/url/url.test.js +0 -12
- package/src/router/view/interface.ts +0 -51
- package/src/router/view/view.html +0 -19
- package/src/router/view/view.js +0 -262
- package/src/router/view/view.spec.js +0 -100
- package/src/router/view/view.test.js +0 -12
- package/src/router/view-hook.spec.js +0 -215
- package/src/router/view-scroll.js +0 -33
- package/src/router/view-scroll.spec.js +0 -72
- package/src/services/anchor-scroll/anchor-scroll.html +0 -76
- package/src/services/anchor-scroll/anchor-scroll.js +0 -147
- package/src/services/exception/exception-handler.js +0 -75
- package/src/services/exception/interface.ts +0 -7
- package/src/services/http/http.html +0 -23
- package/src/services/http/http.js +0 -1109
- package/src/services/http/http.spec.js +0 -4320
- package/src/services/http/http.test.js +0 -11
- package/src/services/http/interface.ts +0 -256
- package/src/services/http/template-request.spec.js +0 -220
- package/src/services/location/interface.ts +0 -70
- package/src/services/location/location.html +0 -22
- package/src/services/location/location.js +0 -1006
- package/src/services/location/location.spec.js +0 -3792
- package/src/services/location/location.test.js +0 -12
- package/src/services/log/interface.ts +0 -39
- package/src/services/log/log.html +0 -19
- package/src/services/log/log.js +0 -74
- package/src/services/log/log.spec.js +0 -64
- package/src/services/log/log.test.js +0 -12
- package/src/services/pubsub/pubsub.html +0 -19
- package/src/services/pubsub/pubsub.js +0 -349
- package/src/services/pubsub/pubsub.spec.js +0 -400
- package/src/services/pubsub/pubsub.test.js +0 -12
- package/src/services/sce/sce.html +0 -19
- package/src/services/sce/sce.js +0 -852
- package/src/services/sce/sce.spec.js +0 -617
- package/src/services/sce/sce.test.js +0 -12
- package/src/services/template-cache/template-cache.html +0 -22
- package/src/services/template-cache/template-cache.js +0 -15
- package/src/services/template-cache/template-cache.spec.js +0 -134
- package/src/services/template-cache/template-cache.test.js +0 -12
- package/src/services/template-request/interface.ts +0 -23
- package/src/services/template-request/template-request.js +0 -142
- package/src/shared/cache.js +0 -7
- package/src/shared/common.js +0 -365
- package/src/shared/common.spec.js +0 -294
- package/src/shared/constants.js +0 -21
- package/src/shared/dom.js +0 -716
- package/src/shared/hof.js +0 -157
- package/src/shared/hof.spec.js +0 -60
- package/src/shared/interface.ts +0 -21
- package/src/shared/min-err.spec.js +0 -178
- package/src/shared/noderef.js +0 -225
- package/src/shared/predicates.js +0 -34
- package/src/shared/queue.js +0 -105
- package/src/shared/queue.spec.js +0 -80
- package/src/shared/shared.html +0 -24
- package/src/shared/shared.test.js +0 -12
- package/src/shared/strings.js +0 -142
- package/src/shared/strings.spec.js +0 -40
- package/src/shared/test-utils.js +0 -47
- package/src/shared/url-utils/interface.ts +0 -54
- package/src/shared/url-utils/url-utils.html +0 -22
- package/src/shared/url-utils/url-utils.js +0 -122
- package/src/shared/url-utils/url-utils.spec.js +0 -148
- package/src/shared/url-utils/url-utils.test.js +0 -12
- package/src/shared/utils.js +0 -1255
- package/src/shared/utils.spec.js +0 -178
- package/src/src.html +0 -21
- package/src/src.test.js +0 -10
- package/tsconfig.json +0 -19
- package/tsconfig.types.json +0 -14
- package/typedoc.json +0 -8
- package/utils/express.js +0 -203
- package/utils/version.cjs +0 -23
- package/vite.config.js +0 -14
|
@@ -1,1515 +0,0 @@
|
|
|
1
|
-
import { Angular } from "../../angular.js";
|
|
2
|
-
import {
|
|
3
|
-
createElementFromHTML,
|
|
4
|
-
dealoc,
|
|
5
|
-
getCacheData,
|
|
6
|
-
getController,
|
|
7
|
-
} from "../../shared/dom.js";
|
|
8
|
-
import { browserTrigger, wait } from "../../shared/test-utils.js";
|
|
9
|
-
import { assert } from "../../shared/utils.js";
|
|
10
|
-
import { FormController } from "./form.js";
|
|
11
|
-
|
|
12
|
-
describe("form", () => {
|
|
13
|
-
let doc;
|
|
14
|
-
let control;
|
|
15
|
-
let scope;
|
|
16
|
-
let $compile;
|
|
17
|
-
let injector;
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
dealoc(document.getElementById("app"));
|
|
21
|
-
window.angular = new Angular();
|
|
22
|
-
window.angular
|
|
23
|
-
.module("myModule", ["ng"])
|
|
24
|
-
.decorator("$exceptionHandler", function () {
|
|
25
|
-
return (exception) => {
|
|
26
|
-
throw new Error(exception);
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
injector = window.angular.bootstrap(document.getElementById("app"), [
|
|
30
|
-
"myModule",
|
|
31
|
-
($compileProvider) => {
|
|
32
|
-
$compileProvider.directive("storeModelCtrl", () => ({
|
|
33
|
-
require: "ngModel",
|
|
34
|
-
link(scope, elm, attr, ctrl) {
|
|
35
|
-
control = ctrl;
|
|
36
|
-
},
|
|
37
|
-
}));
|
|
38
|
-
},
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
|
-
injector.invoke((_$compile_, $rootScope) => {
|
|
42
|
-
$compile = _$compile_;
|
|
43
|
-
scope = $rootScope.$new();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
afterEach(() => {
|
|
48
|
-
dealoc(doc);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("should instantiate form and attach it to DOM", async () => {
|
|
52
|
-
doc = $compile("<form>")(scope);
|
|
53
|
-
await wait();
|
|
54
|
-
expect(getCacheData(doc, "$formController")).toBeTruthy();
|
|
55
|
-
expect(getCacheData(doc, "$formController") instanceof FormController).toBe(
|
|
56
|
-
true,
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("should remove form control references from the form when nested control is removed from the DOM", async () => {
|
|
61
|
-
doc = $compile(
|
|
62
|
-
'<form name="myForm">' +
|
|
63
|
-
'<input ng-if="inputPresent" name="alias" ng-model="value" store-model-ctrl/>' +
|
|
64
|
-
"</form>",
|
|
65
|
-
)(scope);
|
|
66
|
-
await wait();
|
|
67
|
-
scope.inputPresent = true;
|
|
68
|
-
const form = scope.myForm;
|
|
69
|
-
await wait();
|
|
70
|
-
control.$setValidity("required", false);
|
|
71
|
-
await wait();
|
|
72
|
-
|
|
73
|
-
expect(form.alias).toBe(control);
|
|
74
|
-
expect(form.$error.required).toEqual([control]);
|
|
75
|
-
|
|
76
|
-
// remove nested control
|
|
77
|
-
scope.inputPresent = false;
|
|
78
|
-
await wait();
|
|
79
|
-
expect(form.$error.required).toBeFalsy();
|
|
80
|
-
expect(form.alias).toBeUndefined();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should ignore changes in manually removed controls", async () => {
|
|
84
|
-
doc = $compile(
|
|
85
|
-
'<form name="myForm">' +
|
|
86
|
-
'<input name="control" ng-maxlength="1" ng-model="value" store-model-ctrl/>' +
|
|
87
|
-
"</form>",
|
|
88
|
-
)(scope);
|
|
89
|
-
await wait();
|
|
90
|
-
const form = scope.myForm;
|
|
91
|
-
|
|
92
|
-
const input = doc.children[0];
|
|
93
|
-
const inputController = getController(input, "ngModel");
|
|
94
|
-
|
|
95
|
-
input.setAttribute("value", "ab");
|
|
96
|
-
input.dispatchEvent(new Event("change"));
|
|
97
|
-
|
|
98
|
-
// await wait();
|
|
99
|
-
await wait(10);
|
|
100
|
-
expect(form.$error.maxlength).toBeTruthy();
|
|
101
|
-
expect(form.$dirty).toBe(true);
|
|
102
|
-
expect(form.$error.maxlength[0].$name).toBe("control");
|
|
103
|
-
|
|
104
|
-
// remove control
|
|
105
|
-
form.$removeControl(form.control);
|
|
106
|
-
expect(form.control).toBeUndefined();
|
|
107
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
108
|
-
|
|
109
|
-
inputController.$setPristine();
|
|
110
|
-
expect(form.$dirty).toBe(true);
|
|
111
|
-
|
|
112
|
-
form.$setPristine();
|
|
113
|
-
|
|
114
|
-
input.setAttribute("value", "ab");
|
|
115
|
-
input.dispatchEvent(new Event("change"));
|
|
116
|
-
|
|
117
|
-
await wait();
|
|
118
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
119
|
-
expect(form.$dirty).toBe(false);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("should react to validation changes in manually added controls", async () => {
|
|
123
|
-
doc = $compile(
|
|
124
|
-
'<form name="myForm">' +
|
|
125
|
-
'<input name="control" ng-maxlength="1" ng-model="value" store-model-ctrl/>' +
|
|
126
|
-
"</form>",
|
|
127
|
-
)(scope);
|
|
128
|
-
await wait();
|
|
129
|
-
const form = scope.myForm;
|
|
130
|
-
const input = doc.children[0];
|
|
131
|
-
// remove control and invalidate it
|
|
132
|
-
form.$removeControl(control);
|
|
133
|
-
expect(form.control).toBeUndefined();
|
|
134
|
-
await wait();
|
|
135
|
-
input.setAttribute("value", "abc");
|
|
136
|
-
input.dispatchEvent(new Event("change"));
|
|
137
|
-
await wait();
|
|
138
|
-
expect(control.$error.maxlength).toBe(true);
|
|
139
|
-
expect(control.$dirty).toBe(true);
|
|
140
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
141
|
-
expect(form.$dirty).toBe(false);
|
|
142
|
-
// re-add the control; its current validation state is not propagated
|
|
143
|
-
form.$addControl(control);
|
|
144
|
-
await wait();
|
|
145
|
-
expect(form.control).toBe(control);
|
|
146
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
147
|
-
expect(form.$dirty).toBe(false);
|
|
148
|
-
|
|
149
|
-
// Only when the input changes again its validation state is propagated
|
|
150
|
-
input.setAttribute("value", "abcd");
|
|
151
|
-
input.dispatchEvent(new Event("change"));
|
|
152
|
-
|
|
153
|
-
expect(form.$error.maxlength[0]).toEqual(control);
|
|
154
|
-
expect(form.$dirty).toBe(false);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("should use the correct parent when renaming and removing dynamically added controls", async () => {
|
|
158
|
-
scope.controlName = "childControl";
|
|
159
|
-
scope.hasChildControl = true;
|
|
160
|
-
|
|
161
|
-
doc = $compile(
|
|
162
|
-
'<div><form name="myForm">' +
|
|
163
|
-
'<div ng-if="hasChildControl">' +
|
|
164
|
-
'<input name="{{controlName}}" ng-maxlength="1" ng-model="value"/>' +
|
|
165
|
-
"</div>" +
|
|
166
|
-
"</form>" +
|
|
167
|
-
'<form name="otherForm"></form>' +
|
|
168
|
-
"</div>",
|
|
169
|
-
)(scope);
|
|
170
|
-
await wait();
|
|
171
|
-
const form = scope.myForm;
|
|
172
|
-
const { otherForm } = scope;
|
|
173
|
-
const { childControl } = form;
|
|
174
|
-
|
|
175
|
-
// remove child form and add it to another form
|
|
176
|
-
form.$removeControl(childControl);
|
|
177
|
-
otherForm.$addControl(childControl);
|
|
178
|
-
|
|
179
|
-
expect(form.childControl).toBeUndefined();
|
|
180
|
-
expect(otherForm.childControl).toBe(childControl);
|
|
181
|
-
|
|
182
|
-
// rename the childControl
|
|
183
|
-
scope.controlName = "childControlMoved";
|
|
184
|
-
await wait();
|
|
185
|
-
expect(form.childControlMoved).toBeUndefined();
|
|
186
|
-
expect(otherForm.childControl).toBeUndefined();
|
|
187
|
-
expect(otherForm.childControlMoved).toBe(childControl);
|
|
188
|
-
|
|
189
|
-
scope.hasChildControl = false;
|
|
190
|
-
await wait();
|
|
191
|
-
expect(form.childControlMoved).toBeUndefined();
|
|
192
|
-
expect(otherForm.childControlMoved).toBeUndefined();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("should remove scope reference when form with no parent form is removed from the DOM", async () => {
|
|
196
|
-
let formController;
|
|
197
|
-
scope.ctrl = {};
|
|
198
|
-
doc = $compile(
|
|
199
|
-
'<div><form name="ctrl.myForm" ng-if="formPresent">' +
|
|
200
|
-
'<input name="alias" ng-model="value" />' +
|
|
201
|
-
"</form></div>",
|
|
202
|
-
)(scope);
|
|
203
|
-
await wait();
|
|
204
|
-
expect(scope.ctrl.myForm).toBeUndefined();
|
|
205
|
-
|
|
206
|
-
scope.$apply("formPresent = true");
|
|
207
|
-
await wait();
|
|
208
|
-
|
|
209
|
-
expect(scope.ctrl.myForm).toBeDefined();
|
|
210
|
-
|
|
211
|
-
formController = getController(doc.querySelector("form"), "form");
|
|
212
|
-
expect(scope.ctrl.myForm == formController).toBeTrue();
|
|
213
|
-
|
|
214
|
-
scope.$apply("formPresent = false");
|
|
215
|
-
await wait();
|
|
216
|
-
|
|
217
|
-
expect(doc.innerText).toBe("");
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("should use ngForm value as form name", async () => {
|
|
221
|
-
doc = $compile(
|
|
222
|
-
'<div ng-form="myForm">' +
|
|
223
|
-
'<input type="text" name="alias" ng-model="value"/>' +
|
|
224
|
-
"</div>",
|
|
225
|
-
)(scope);
|
|
226
|
-
await wait();
|
|
227
|
-
|
|
228
|
-
expect(scope.myForm).toBeDefined();
|
|
229
|
-
expect(scope.myForm.alias).toBeDefined();
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it("should use ngForm value as form name when nested inside form", async () => {
|
|
233
|
-
doc = $compile(
|
|
234
|
-
'<form name="myForm">' +
|
|
235
|
-
'<div ng-form="nestedForm"><input type="text" name="alias" ng-model="value"/></div>' +
|
|
236
|
-
"</form>",
|
|
237
|
-
)(scope);
|
|
238
|
-
await wait();
|
|
239
|
-
|
|
240
|
-
expect(scope.myForm).toBeDefined();
|
|
241
|
-
expect(scope.myForm.nestedForm).toBeDefined();
|
|
242
|
-
expect(scope.myForm.nestedForm.alias).toBeDefined();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("should publish form to scope when name attr is defined", async () => {
|
|
246
|
-
doc = $compile('<form name="myForm"></form>')(scope);
|
|
247
|
-
await wait();
|
|
248
|
-
|
|
249
|
-
expect(scope.myForm).toBeTruthy();
|
|
250
|
-
expect(getCacheData(doc, "$formController")).toBeTruthy();
|
|
251
|
-
expect(getCacheData(doc, "$formController")).toEqual(scope.myForm);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("should support expression in form name", async () => {
|
|
255
|
-
doc = $compile('<form name="obj.myForm"></form>')(scope);
|
|
256
|
-
await wait();
|
|
257
|
-
expect(scope.obj).toBeDefined();
|
|
258
|
-
expect(scope.obj.myForm).toBeTruthy();
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it("should support two forms on a single scope", async () => {
|
|
262
|
-
doc = $compile(`
|
|
263
|
-
<div>
|
|
264
|
-
<form name="formA">
|
|
265
|
-
<input name="firstName" ng-model="firstName" required>
|
|
266
|
-
</form>
|
|
267
|
-
<form name="formB">
|
|
268
|
-
<input name="lastName" ng-model="lastName" required>
|
|
269
|
-
</form>
|
|
270
|
-
</div>
|
|
271
|
-
`)(scope);
|
|
272
|
-
await wait();
|
|
273
|
-
|
|
274
|
-
expect(scope.formA.$error.required.length).toBe(1);
|
|
275
|
-
expect(scope.formA.$error.required).toEqual([scope.formA.firstName]);
|
|
276
|
-
expect(scope.formB.$error.required.length).toBe(1);
|
|
277
|
-
expect(scope.formB.$error.required).toEqual([scope.formB.lastName]);
|
|
278
|
-
|
|
279
|
-
const inputA = doc.querySelectorAll("input")[0];
|
|
280
|
-
const inputB = doc.querySelectorAll("input")[1];
|
|
281
|
-
|
|
282
|
-
inputA.setAttribute("value", "val1");
|
|
283
|
-
inputA.dispatchEvent(new Event("change"));
|
|
284
|
-
await wait();
|
|
285
|
-
inputB.setAttribute("value", "val2");
|
|
286
|
-
inputB.dispatchEvent(new Event("change"));
|
|
287
|
-
await wait();
|
|
288
|
-
expect(scope.firstName).toBe("val1");
|
|
289
|
-
expect(scope.lastName).toBe("val2");
|
|
290
|
-
await wait();
|
|
291
|
-
expect(scope.formA.$error.required).toBeFalsy();
|
|
292
|
-
expect(scope.formB.$error.required).toBeFalsy();
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it("should publish widgets", async () => {
|
|
296
|
-
doc = createElementFromHTML(
|
|
297
|
-
'<form name="form"><input type="text" name="w1" ng-model="some" /></form>',
|
|
298
|
-
);
|
|
299
|
-
$compile(doc)(scope);
|
|
300
|
-
await wait();
|
|
301
|
-
const widget = scope.form.w1;
|
|
302
|
-
expect(widget).toBeDefined();
|
|
303
|
-
expect(widget.$pristine).toBe(true);
|
|
304
|
-
expect(widget.$dirty).toBe(false);
|
|
305
|
-
expect(widget.$valid).toBe(true);
|
|
306
|
-
expect(widget.$invalid).toBe(false);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
it('should throw an exception if an input has name="hasOwnProperty"', async () => {
|
|
310
|
-
doc = createElementFromHTML(
|
|
311
|
-
'<form name="form">' +
|
|
312
|
-
'<input name="hasOwnProperty" ng-model="some" />' +
|
|
313
|
-
'<input name="other" ng-model="someOther" />' +
|
|
314
|
-
"</form>",
|
|
315
|
-
);
|
|
316
|
-
expect(() => {
|
|
317
|
-
$compile(doc)(scope);
|
|
318
|
-
}).toThrowError();
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
describe("triggering commit value on submit", () => {
|
|
322
|
-
it("should trigger update on form submit", async () => {
|
|
323
|
-
const form = $compile(
|
|
324
|
-
'<form name="test" ng-model-options="{ updateOn: \'submit\' }" >' +
|
|
325
|
-
'<input type="text" ng-model="name" />' +
|
|
326
|
-
"</form>",
|
|
327
|
-
)(scope);
|
|
328
|
-
await wait();
|
|
329
|
-
const inputElm = form.children[0];
|
|
330
|
-
|
|
331
|
-
inputElm.setAttribute("value", "a");
|
|
332
|
-
inputElm.dispatchEvent(new Event("change"));
|
|
333
|
-
expect(scope.name).toEqual(undefined);
|
|
334
|
-
|
|
335
|
-
form.dispatchEvent(new Event("submit"));
|
|
336
|
-
expect(scope.name).toEqual("a");
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it("should trigger update on form submit with nested forms", async () => {
|
|
340
|
-
const form = $compile(
|
|
341
|
-
'<div><form name="test" ng-model-options="{ updateOn: \'submit\' }" >' +
|
|
342
|
-
'<div ng-form name="child">' +
|
|
343
|
-
'<input type="text" ng-model="name" />' +
|
|
344
|
-
"</div>" +
|
|
345
|
-
"</form></div>",
|
|
346
|
-
)(scope);
|
|
347
|
-
await wait();
|
|
348
|
-
const inputElm = form.querySelector("input");
|
|
349
|
-
|
|
350
|
-
inputElm.setAttribute("value", "a");
|
|
351
|
-
inputElm.dispatchEvent(new Event("change"));
|
|
352
|
-
await wait();
|
|
353
|
-
expect(scope.name).toEqual(undefined);
|
|
354
|
-
browserTrigger(form.firstChild, "submit");
|
|
355
|
-
await wait();
|
|
356
|
-
expect(scope.name).toEqual("a");
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it("should trigger update before ng-submit is invoked", async () => {
|
|
360
|
-
const form = $compile(
|
|
361
|
-
'<form name="test" ng-submit="submit()" ' +
|
|
362
|
-
"ng-model-options=\"{ updateOn: 'submit' }\" >" +
|
|
363
|
-
'<input type="text" ng-model="name" />' +
|
|
364
|
-
"</form>",
|
|
365
|
-
)(scope);
|
|
366
|
-
await wait();
|
|
367
|
-
const inputElm = form.children[0];
|
|
368
|
-
inputElm.setAttribute("value", "a");
|
|
369
|
-
inputElm.dispatchEvent(new Event("change"));
|
|
370
|
-
scope.submit = jasmine.createSpy("submit").and.callFake(() => {
|
|
371
|
-
expect(scope.name).toEqual("a");
|
|
372
|
-
});
|
|
373
|
-
// browserTrigger(form, "submit");
|
|
374
|
-
form.dispatchEvent(new Event("submit"));
|
|
375
|
-
expect(scope.submit).toHaveBeenCalled();
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
describe("rollback view value", () => {
|
|
380
|
-
it("should trigger rollback on form controls", async () => {
|
|
381
|
-
const form = $compile(
|
|
382
|
-
'<form name="test" ng-model-options="{ updateOn: \'submit\' }" >' +
|
|
383
|
-
'<input type="text" ng-model="name" />' +
|
|
384
|
-
'<button ng-click="test.$rollbackViewValue()" />' +
|
|
385
|
-
"</form>",
|
|
386
|
-
)(scope);
|
|
387
|
-
const inputElm = form.children[0];
|
|
388
|
-
inputElm.setAttribute("value", "a");
|
|
389
|
-
inputElm.dispatchEvent(new Event("click"));
|
|
390
|
-
expect(inputElm.value).toBe("a");
|
|
391
|
-
form.querySelector("button").click();
|
|
392
|
-
expect(inputElm.value).toBe("");
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
it("should trigger rollback on form controls with nested forms", async () => {
|
|
396
|
-
const form = $compile(
|
|
397
|
-
'<form name="test" ng-model-options="{ updateOn: \'submit\' }" >' +
|
|
398
|
-
'<div ng-form name="child">' +
|
|
399
|
-
'<input type="text" ng-model="name" />' +
|
|
400
|
-
"</div>" +
|
|
401
|
-
'<button ng-click="test.$rollbackViewValue()" />' +
|
|
402
|
-
"</form>",
|
|
403
|
-
)(scope);
|
|
404
|
-
const inputElm = form.querySelector("input");
|
|
405
|
-
inputElm.setAttribute("value", "a");
|
|
406
|
-
inputElm.dispatchEvent(new Event("click"));
|
|
407
|
-
expect(inputElm.value).toBe("a");
|
|
408
|
-
form.querySelector("button").click();
|
|
409
|
-
await wait();
|
|
410
|
-
expect(inputElm.value).toBe("");
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
describe("preventing default submission", () => {
|
|
415
|
-
it("should prevent form submission", (done) => {
|
|
416
|
-
let nextTurn = false;
|
|
417
|
-
let submitted = false;
|
|
418
|
-
let reloadPrevented;
|
|
419
|
-
|
|
420
|
-
doc = createElementFromHTML(
|
|
421
|
-
'<form ng-submit="submitMe()">' +
|
|
422
|
-
'<input type="submit" value="submit">' +
|
|
423
|
-
"</form>",
|
|
424
|
-
);
|
|
425
|
-
// Support: Chrome 60+ (on Windows)
|
|
426
|
-
// We need to add the form to the DOM in order for `submit` events to be properly fired.
|
|
427
|
-
document.body.appendChild(doc);
|
|
428
|
-
|
|
429
|
-
const assertPreventDefaultListener = function (e) {
|
|
430
|
-
reloadPrevented = e.defaultPrevented || e.returnValue === false;
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
$compile(doc)(scope);
|
|
434
|
-
|
|
435
|
-
scope.submitMe = function () {
|
|
436
|
-
submitted = true;
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
doc.addEventListener("submit", assertPreventDefaultListener);
|
|
440
|
-
doc.querySelector("input").click();
|
|
441
|
-
|
|
442
|
-
// let the browser process all events (and potentially reload the page)
|
|
443
|
-
window.setTimeout(() => {
|
|
444
|
-
expect(reloadPrevented).toBe(true);
|
|
445
|
-
expect(submitted).toBe(true);
|
|
446
|
-
|
|
447
|
-
// prevent mem leak in test
|
|
448
|
-
doc.removeEventListener("submit", assertPreventDefaultListener);
|
|
449
|
-
done();
|
|
450
|
-
}, 100);
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
it("should prevent the default when the form is destroyed by a submission via a click event", (done) => {
|
|
454
|
-
doc = createElementFromHTML(
|
|
455
|
-
"<div>" +
|
|
456
|
-
'<form ng-submit="submitMe()">' +
|
|
457
|
-
'<button type="submit" ng-click="destroy()"></button>' +
|
|
458
|
-
"</form>" +
|
|
459
|
-
"</div>",
|
|
460
|
-
);
|
|
461
|
-
|
|
462
|
-
const form = doc.querySelector("form");
|
|
463
|
-
let destroyed = false;
|
|
464
|
-
let nextTurn = false;
|
|
465
|
-
let submitted = false;
|
|
466
|
-
let reloadPrevented = "never called";
|
|
467
|
-
|
|
468
|
-
scope.destroy = function () {
|
|
469
|
-
// yes, I know, scope methods should not do direct DOM manipulation, but I wanted to keep
|
|
470
|
-
// this test small. Imagine that the destroy action will cause a model change (e.g.
|
|
471
|
-
// $location change) that will cause some directive to destroy the dom (e.g. ngView+$route)
|
|
472
|
-
doc.innerHTML = "";
|
|
473
|
-
destroyed = true;
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
scope.submitMe = function () {
|
|
477
|
-
submitted = true;
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
const assertPreventDefaultListener = function (e) {
|
|
481
|
-
reloadPrevented = e.defaultPrevented || e.returnValue === false;
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
$compile(doc)(scope);
|
|
485
|
-
|
|
486
|
-
form.addEventListener("submit", assertPreventDefaultListener);
|
|
487
|
-
|
|
488
|
-
form.querySelector("button").click();
|
|
489
|
-
|
|
490
|
-
// let the browser process all events (and potentially reload the page)
|
|
491
|
-
window.setTimeout(() => {
|
|
492
|
-
nextTurn = true;
|
|
493
|
-
expect(doc.innerHTML).toBe("");
|
|
494
|
-
expect(destroyed).toBe(true);
|
|
495
|
-
expect(submitted).toBe(false);
|
|
496
|
-
// this is known corner-case that is not currently handled
|
|
497
|
-
// the issue is that the submit listener is destroyed before
|
|
498
|
-
// the event propagates there. we can fix this if we see
|
|
499
|
-
// the issue in the wild, I'm not going to bother to do it
|
|
500
|
-
// now. (i)
|
|
501
|
-
|
|
502
|
-
// Support: Chrome 60+ (on Windows)
|
|
503
|
-
// Chrome 60+ on Windows does not fire `submit` events when the form is not attached to
|
|
504
|
-
// the DOM. Verify that the `submit` listener was either never fired or (if fired) the
|
|
505
|
-
// reload was prevented.
|
|
506
|
-
expect(reloadPrevented).not.toBe(false);
|
|
507
|
-
|
|
508
|
-
// prevent mem leak in test
|
|
509
|
-
form.removeEventListener("submit", assertPreventDefaultListener);
|
|
510
|
-
done();
|
|
511
|
-
}, 100);
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
it("should NOT prevent form submission if action attribute present", () => {
|
|
515
|
-
const callback = jasmine.createSpy("submit").and.callFake((event) => {
|
|
516
|
-
expect(event.defaultPrevented).toBe(false);
|
|
517
|
-
event.preventDefault();
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
doc = $compile('<form action="some.py"></form>')(scope);
|
|
521
|
-
doc.addEventListener("submit", callback);
|
|
522
|
-
|
|
523
|
-
//browserTrigger(doc, "submit");
|
|
524
|
-
doc.dispatchEvent(new Event("submit"));
|
|
525
|
-
expect(callback).toHaveBeenCalled();
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
describe("nested forms", () => {
|
|
530
|
-
it("should chain nested forms", () => {
|
|
531
|
-
doc = createElementFromHTML(
|
|
532
|
-
'<ng-form name="parent">' +
|
|
533
|
-
'<ng-form name="child">' +
|
|
534
|
-
'<input ng-model="modelA" name="inputA">' +
|
|
535
|
-
'<input ng-model="modelB" name="inputB">' +
|
|
536
|
-
"</ng-form>" +
|
|
537
|
-
"</ng-form>",
|
|
538
|
-
);
|
|
539
|
-
$compile(doc)(scope);
|
|
540
|
-
|
|
541
|
-
const { parent } = scope;
|
|
542
|
-
const { child } = scope;
|
|
543
|
-
const { inputA } = child;
|
|
544
|
-
const { inputB } = child;
|
|
545
|
-
|
|
546
|
-
inputA.$setValidity("MyError", false);
|
|
547
|
-
inputB.$setValidity("MyError", false);
|
|
548
|
-
expect(parent.$error.MyError).toEqual([child]);
|
|
549
|
-
expect(child.$error.MyError).toEqual([inputA, inputB]);
|
|
550
|
-
|
|
551
|
-
inputA.$setValidity("MyError", true);
|
|
552
|
-
expect(parent.$error.MyError).toEqual([child]);
|
|
553
|
-
expect(child.$error.MyError).toEqual([inputB]);
|
|
554
|
-
|
|
555
|
-
inputB.$setValidity("MyError", true);
|
|
556
|
-
expect(parent.$error.MyError).toBeFalsy();
|
|
557
|
-
expect(child.$error.MyError).toBeFalsy();
|
|
558
|
-
|
|
559
|
-
child.$setDirty();
|
|
560
|
-
expect(parent.$dirty).toBeTruthy();
|
|
561
|
-
|
|
562
|
-
child.$setSubmitted();
|
|
563
|
-
expect(parent.$submitted).toBeTruthy();
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
it("should set $submitted to true on child forms when parent is submitted", () => {
|
|
567
|
-
doc = createElementFromHTML(
|
|
568
|
-
'<ng-form name="parent">' +
|
|
569
|
-
'<ng-form name="child">' +
|
|
570
|
-
'<input ng-model="modelA" name="inputA">' +
|
|
571
|
-
'<input ng-model="modelB" name="inputB">' +
|
|
572
|
-
"</ng-form>" +
|
|
573
|
-
"</ng-form>",
|
|
574
|
-
);
|
|
575
|
-
$compile(doc)(scope);
|
|
576
|
-
|
|
577
|
-
const { parent } = scope;
|
|
578
|
-
const { child } = scope;
|
|
579
|
-
|
|
580
|
-
parent.$setSubmitted();
|
|
581
|
-
expect(parent.$submitted).toBeTruthy();
|
|
582
|
-
expect(child.$submitted).toBeTruthy();
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
it("should not propagate $submitted state on removed child forms when parent is submitted", async () => {
|
|
586
|
-
doc = createElementFromHTML(
|
|
587
|
-
'<ng-form name="parent">' +
|
|
588
|
-
'<ng-form name="child">' +
|
|
589
|
-
'<ng-form name="grandchild">' +
|
|
590
|
-
'<input ng-model="modelA" name="inputA">' +
|
|
591
|
-
"</ng-form>" +
|
|
592
|
-
"</ng-form>" +
|
|
593
|
-
"</ng-form>",
|
|
594
|
-
);
|
|
595
|
-
$compile(doc)(scope);
|
|
596
|
-
await wait();
|
|
597
|
-
const { parent } = scope;
|
|
598
|
-
const { child } = scope;
|
|
599
|
-
const { grandchild } = scope;
|
|
600
|
-
const ggchild = scope.greatgrandchild;
|
|
601
|
-
|
|
602
|
-
parent.$removeControl(child);
|
|
603
|
-
|
|
604
|
-
parent.$setSubmitted();
|
|
605
|
-
expect(parent.$submitted).toBeTruthy();
|
|
606
|
-
expect(child.$submitted).not.toBeTruthy();
|
|
607
|
-
expect(grandchild.$submitted).not.toBeTruthy();
|
|
608
|
-
|
|
609
|
-
parent.$addControl(child);
|
|
610
|
-
expect(parent.$submitted).toBeTruthy();
|
|
611
|
-
expect(child.$submitted).not.toBeTruthy();
|
|
612
|
-
expect(grandchild.$submitted).not.toBeTruthy();
|
|
613
|
-
|
|
614
|
-
parent.$setSubmitted();
|
|
615
|
-
expect(parent.$submitted).toBeTruthy();
|
|
616
|
-
expect(child.$submitted).toBeTruthy();
|
|
617
|
-
expect(grandchild.$submitted).toBeTruthy();
|
|
618
|
-
|
|
619
|
-
parent.$removeControl(child);
|
|
620
|
-
|
|
621
|
-
expect(parent.$submitted).toBeTruthy();
|
|
622
|
-
expect(child.$submitted).toBeTruthy();
|
|
623
|
-
expect(grandchild.$submitted).toBeTruthy();
|
|
624
|
-
|
|
625
|
-
parent.$setPristine(); // sets $submitted to false
|
|
626
|
-
expect(parent.$submitted).not.toBeTruthy();
|
|
627
|
-
expect(child.$submitted).toBeTruthy();
|
|
628
|
-
expect(grandchild.$submitted).toBeTruthy();
|
|
629
|
-
|
|
630
|
-
grandchild.$setPristine();
|
|
631
|
-
expect(grandchild.$submitted).not.toBeTruthy();
|
|
632
|
-
|
|
633
|
-
child.$setSubmitted();
|
|
634
|
-
expect(parent.$submitted).not.toBeTruthy();
|
|
635
|
-
expect(child.$submitted).toBeTruthy();
|
|
636
|
-
expect(grandchild.$submitted).toBeTruthy();
|
|
637
|
-
|
|
638
|
-
child.$setPristine();
|
|
639
|
-
expect(parent.$submitted).not.toBeTruthy();
|
|
640
|
-
expect(child.$submitted).not.toBeTruthy();
|
|
641
|
-
expect(grandchild.$submitted).not.toBeTruthy();
|
|
642
|
-
|
|
643
|
-
// Test upwards submission setting
|
|
644
|
-
grandchild.$setSubmitted();
|
|
645
|
-
expect(parent.$submitted).not.toBeTruthy();
|
|
646
|
-
expect(child.$submitted).toBeTruthy();
|
|
647
|
-
expect(grandchild.$submitted).toBeTruthy();
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
it("should set $submitted to true on child and parent forms when form is submitted", async () => {
|
|
651
|
-
doc = createElementFromHTML(
|
|
652
|
-
'<ng-form name="parent">' +
|
|
653
|
-
'<ng-form name="child">' +
|
|
654
|
-
'<ng-form name="grandchild">' +
|
|
655
|
-
'<input ng-model="modelA" name="inputA">' +
|
|
656
|
-
'<input ng-model="modelB" name="inputB">' +
|
|
657
|
-
"</ng-form>" +
|
|
658
|
-
"</ng-form>" +
|
|
659
|
-
"</ng-form>",
|
|
660
|
-
);
|
|
661
|
-
$compile(doc)(scope);
|
|
662
|
-
await wait();
|
|
663
|
-
const { parent } = scope;
|
|
664
|
-
const { child } = scope;
|
|
665
|
-
const { grandchild } = scope;
|
|
666
|
-
|
|
667
|
-
child.$setSubmitted();
|
|
668
|
-
|
|
669
|
-
expect(parent.$submitted).toBeTruthy();
|
|
670
|
-
expect(child.$submitted).toBeTruthy();
|
|
671
|
-
expect(grandchild.$submitted).toBeTruthy();
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
// TODO These tests relied on JQ lite to call destroy on the elements being removed
|
|
675
|
-
// xit("should deregister a child form when its DOM is removed", async () => {
|
|
676
|
-
// doc = createElementFromHTML(
|
|
677
|
-
// '<form name="parent">' +
|
|
678
|
-
// '<div ng-form name="child">' +
|
|
679
|
-
// '<input ng-model="modelA" name="inputA" required>' +
|
|
680
|
-
// "</div>" +
|
|
681
|
-
// "</form>",
|
|
682
|
-
// );
|
|
683
|
-
// $compile(doc)(scope);
|
|
684
|
-
// await wait();
|
|
685
|
-
//
|
|
686
|
-
// const parent = scope.parent,
|
|
687
|
-
// child = scope.child;
|
|
688
|
-
//
|
|
689
|
-
// expect(parent).toBeDefined();
|
|
690
|
-
// expect(child).toBeDefined();
|
|
691
|
-
// expect(parent.$error.required).toEqual([child]);
|
|
692
|
-
//
|
|
693
|
-
// doc.replaceChildren(); //remove child
|
|
694
|
-
// expect(parent.child).toBeUndefined();
|
|
695
|
-
// expect(scope.child).toBeUndefined();
|
|
696
|
-
// expect(parent.$error.required).toBeFalsy();
|
|
697
|
-
// });
|
|
698
|
-
//
|
|
699
|
-
// xit("should deregister a child form whose name is an expression when its DOM is removed", async () => {
|
|
700
|
-
// doc = createElementFromHTML(
|
|
701
|
-
// '<form name="parent">' +
|
|
702
|
-
// '<div ng-form name="child.form">' +
|
|
703
|
-
// '<input ng-model="modelA" name="inputA" required>' +
|
|
704
|
-
// "</div>" +
|
|
705
|
-
// "</form>",
|
|
706
|
-
// );
|
|
707
|
-
// $compile(doc)(scope);
|
|
708
|
-
// await wait();
|
|
709
|
-
//
|
|
710
|
-
// const { parent } = scope;
|
|
711
|
-
// const child = scope.child.form;
|
|
712
|
-
// expect(parent).toBeDefined();
|
|
713
|
-
// expect(child).toBeDefined();
|
|
714
|
-
// expect(parent.$error.required).toEqual([child]);
|
|
715
|
-
// doc.replaceChildren(); // remove child
|
|
716
|
-
//
|
|
717
|
-
// await wait();
|
|
718
|
-
//
|
|
719
|
-
// expect(parent.child.form).toBeUndefined();
|
|
720
|
-
// expect(scope.child.form).toBeUndefined();
|
|
721
|
-
// expect(parent.$error.required).toBeFalsy();
|
|
722
|
-
// });
|
|
723
|
-
|
|
724
|
-
it("should deregister a input when it is removed from DOM", async () => {
|
|
725
|
-
doc = createElementFromHTML(
|
|
726
|
-
'<form name="parent">' +
|
|
727
|
-
'<div ng-form name="child">' +
|
|
728
|
-
'<input ng-if="inputPresent" ng-model="modelA" name="inputA" required maxlength="10">' +
|
|
729
|
-
"</div>" +
|
|
730
|
-
"</form>",
|
|
731
|
-
);
|
|
732
|
-
$compile(doc)(scope);
|
|
733
|
-
scope.inputPresent = true;
|
|
734
|
-
await wait();
|
|
735
|
-
|
|
736
|
-
const { parent } = scope;
|
|
737
|
-
const { child } = scope;
|
|
738
|
-
const input = child.inputA;
|
|
739
|
-
|
|
740
|
-
expect(parent).toBeDefined();
|
|
741
|
-
expect(child).toBeDefined();
|
|
742
|
-
|
|
743
|
-
expect(parent.$error.required).toEqual([child]);
|
|
744
|
-
expect(parent.$$success.maxlength).toEqual([child]);
|
|
745
|
-
|
|
746
|
-
expect(child.$error.required).toEqual([input]);
|
|
747
|
-
expect(child.$$success.maxlength).toEqual([input]);
|
|
748
|
-
|
|
749
|
-
expect(doc.classList.contains("ng-invalid")).toBe(true);
|
|
750
|
-
expect(doc.classList.contains("ng-invalid-required")).toBe(true);
|
|
751
|
-
expect(doc.classList.contains("ng-valid-maxlength")).toBe(true);
|
|
752
|
-
expect(doc.querySelector("div").classList.contains("ng-invalid")).toBe(
|
|
753
|
-
true,
|
|
754
|
-
);
|
|
755
|
-
expect(
|
|
756
|
-
doc.querySelector("div").classList.contains("ng-invalid-required"),
|
|
757
|
-
).toBe(true);
|
|
758
|
-
expect(
|
|
759
|
-
doc.querySelector("div").classList.contains("ng-valid-maxlength"),
|
|
760
|
-
).toBe(true);
|
|
761
|
-
|
|
762
|
-
// remove child input
|
|
763
|
-
scope.$apply("inputPresent = false");
|
|
764
|
-
await wait();
|
|
765
|
-
expect(parent.$error.required).toBeFalsy();
|
|
766
|
-
expect(parent.$$success.maxlength).toBeFalsy();
|
|
767
|
-
|
|
768
|
-
expect(child.$error.required).toBeFalsy();
|
|
769
|
-
expect(child.$$success.maxlength).toBeFalsy();
|
|
770
|
-
|
|
771
|
-
expect(doc.classList.contains("ng-valid")).toBe(true);
|
|
772
|
-
expect(doc.classList.contains("ng-valid-required")).toBe(false);
|
|
773
|
-
expect(doc.classList.contains("ng-invalid-required")).toBe(false);
|
|
774
|
-
expect(doc.classList.contains("ng-valid-maxlength")).toBe(false);
|
|
775
|
-
expect(doc.classList.contains("ng-invalid-maxlength")).toBe(false);
|
|
776
|
-
|
|
777
|
-
expect(doc.querySelector("div").classList.contains("ng-valid")).toBe(
|
|
778
|
-
true,
|
|
779
|
-
);
|
|
780
|
-
expect(
|
|
781
|
-
doc.querySelector("div").classList.contains("ng-valid-required"),
|
|
782
|
-
).toBe(false);
|
|
783
|
-
expect(
|
|
784
|
-
doc.querySelector("div").classList.contains("ng-invalid-required"),
|
|
785
|
-
).toBe(false);
|
|
786
|
-
expect(
|
|
787
|
-
doc.querySelector("div").classList.contains("ng-valid-maxlength"),
|
|
788
|
-
).toBe(false);
|
|
789
|
-
expect(
|
|
790
|
-
doc.querySelector("div").classList.contains("ng-invalid-maxlength"),
|
|
791
|
-
).toBe(false);
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
it("should deregister a input that is $pending when it is removed from DOM", async () => {
|
|
795
|
-
doc = createElementFromHTML(
|
|
796
|
-
'<form name="parent">' +
|
|
797
|
-
'<div ng-form name="child">' +
|
|
798
|
-
'<input ng-if="inputPresent" ng-model="modelA" name="inputA">' +
|
|
799
|
-
"</div>" +
|
|
800
|
-
"</form>",
|
|
801
|
-
);
|
|
802
|
-
$compile(doc)(scope);
|
|
803
|
-
scope.$apply("inputPresent = true");
|
|
804
|
-
await wait();
|
|
805
|
-
const { parent } = scope;
|
|
806
|
-
const { child } = scope;
|
|
807
|
-
const input = child.inputA;
|
|
808
|
-
|
|
809
|
-
child.inputA.$setValidity("fake", undefined);
|
|
810
|
-
await wait();
|
|
811
|
-
expect(parent).toBeDefined();
|
|
812
|
-
expect(child).toBeDefined();
|
|
813
|
-
|
|
814
|
-
expect(parent.$pending.fake).toEqual([child]);
|
|
815
|
-
expect(child.$pending.fake).toEqual([input]);
|
|
816
|
-
|
|
817
|
-
expect(doc.classList.contains("ng-pending")).toBe(true);
|
|
818
|
-
expect(doc.querySelector("div").classList.contains("ng-pending")).toBe(
|
|
819
|
-
true,
|
|
820
|
-
);
|
|
821
|
-
|
|
822
|
-
// remove child input
|
|
823
|
-
scope.$apply("inputPresent = false");
|
|
824
|
-
await wait();
|
|
825
|
-
expect(parent.$pending).toBeUndefined();
|
|
826
|
-
expect(child.$pending).toBeUndefined();
|
|
827
|
-
|
|
828
|
-
expect(doc.classList.contains("ng-pending")).toBe(false);
|
|
829
|
-
expect(doc.querySelector("div").classList.contains("ng-pending")).toBe(
|
|
830
|
-
false,
|
|
831
|
-
);
|
|
832
|
-
});
|
|
833
|
-
|
|
834
|
-
it("should leave the parent form invalid when deregister a removed input", async () => {
|
|
835
|
-
doc = createElementFromHTML(
|
|
836
|
-
'<form name="parent">' +
|
|
837
|
-
'<div ng-form name="child">' +
|
|
838
|
-
'<input ng-if="inputPresent" ng-model="modelA" name="inputA" required>' +
|
|
839
|
-
'<input ng-model="modelB" name="inputB" required>' +
|
|
840
|
-
"</div>" +
|
|
841
|
-
"</form>",
|
|
842
|
-
);
|
|
843
|
-
$compile(doc)(scope);
|
|
844
|
-
scope.inputPresent = true;
|
|
845
|
-
await wait();
|
|
846
|
-
|
|
847
|
-
const { parent } = scope;
|
|
848
|
-
const { child } = scope;
|
|
849
|
-
const { inputA } = child;
|
|
850
|
-
const { inputB } = child;
|
|
851
|
-
|
|
852
|
-
expect(parent).toBeDefined();
|
|
853
|
-
expect(child).toBeDefined();
|
|
854
|
-
expect(parent.$error.required).toEqual([child]);
|
|
855
|
-
expect(child.$error.required).toEqual([inputB, inputA]);
|
|
856
|
-
|
|
857
|
-
// remove child input
|
|
858
|
-
scope.inputPresent = false;
|
|
859
|
-
await wait();
|
|
860
|
-
|
|
861
|
-
expect(parent.$error.required).toEqual([child]);
|
|
862
|
-
expect(child.$error.required).toEqual([inputB]);
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
it("should ignore changes in manually removed child forms", async () => {
|
|
866
|
-
doc = $compile(
|
|
867
|
-
'<form name="myForm">' +
|
|
868
|
-
'<ng-form name="childform">' +
|
|
869
|
-
'<input name="childformcontrol" ng-maxlength="1" ng-model="value"/>' +
|
|
870
|
-
"</ng-form>" +
|
|
871
|
-
"</form>",
|
|
872
|
-
)(scope);
|
|
873
|
-
await wait();
|
|
874
|
-
const form = scope.myForm;
|
|
875
|
-
const childformController = getController(
|
|
876
|
-
doc.querySelector("ng-form"),
|
|
877
|
-
"form",
|
|
878
|
-
);
|
|
879
|
-
|
|
880
|
-
const input = doc.children[0].firstChild;
|
|
881
|
-
const inputController = getController(input, "ngModel");
|
|
882
|
-
|
|
883
|
-
// changeInputValue(input, "ab");
|
|
884
|
-
input.setAttribute("value", "ab");
|
|
885
|
-
input.dispatchEvent(new Event("change"));
|
|
886
|
-
|
|
887
|
-
await wait();
|
|
888
|
-
|
|
889
|
-
expect(form.$dirty).toBe(true);
|
|
890
|
-
expect(form.$error.maxlength).toBeTruthy();
|
|
891
|
-
expect(form.$error.maxlength[0].$name).toBe("childform");
|
|
892
|
-
|
|
893
|
-
inputController.$setPristine();
|
|
894
|
-
await wait();
|
|
895
|
-
expect(form.$dirty).toBe(true);
|
|
896
|
-
|
|
897
|
-
form.$setPristine();
|
|
898
|
-
|
|
899
|
-
// remove child form
|
|
900
|
-
form.$removeControl(childformController);
|
|
901
|
-
await wait();
|
|
902
|
-
expect(form.childform).toBeUndefined();
|
|
903
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
904
|
-
|
|
905
|
-
// changeInputValue(input, "abc");
|
|
906
|
-
input.setAttribute("value", "abc");
|
|
907
|
-
input.dispatchEvent(new Event("change"));
|
|
908
|
-
await wait();
|
|
909
|
-
|
|
910
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
911
|
-
expect(form.$dirty).toBe(false);
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
it("should react to changes in manually added child forms", async () => {
|
|
915
|
-
doc = $compile(
|
|
916
|
-
'<form name="myForm">' +
|
|
917
|
-
'<ng-form name="childForm">' +
|
|
918
|
-
'<input name="childformcontrol" ng-maxlength="1" ng-model="value" />' +
|
|
919
|
-
"</ng-form>" +
|
|
920
|
-
"</form>",
|
|
921
|
-
)(scope);
|
|
922
|
-
await wait();
|
|
923
|
-
|
|
924
|
-
const form = scope.myForm;
|
|
925
|
-
const childFormController = getController(
|
|
926
|
-
doc.querySelector("ng-form"),
|
|
927
|
-
"form",
|
|
928
|
-
);
|
|
929
|
-
|
|
930
|
-
const input = doc.children[0].firstChild;
|
|
931
|
-
|
|
932
|
-
// remove child form so we can add it manually
|
|
933
|
-
form.$removeControl(childFormController);
|
|
934
|
-
// changeInputValue(input, "ab");
|
|
935
|
-
input.setAttribute("value", "ab");
|
|
936
|
-
input.dispatchEvent(new Event("change"));
|
|
937
|
-
|
|
938
|
-
expect(form.childForm).toBeUndefined();
|
|
939
|
-
expect(form.$dirty).toBe(false);
|
|
940
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
941
|
-
|
|
942
|
-
// re-add the child form; its current validation state is not propagated
|
|
943
|
-
form.$addControl(childFormController);
|
|
944
|
-
expect(form.childForm).toBe(childFormController);
|
|
945
|
-
expect(form.$error.maxlength).toBeFalsy();
|
|
946
|
-
expect(form.$dirty).toBe(false);
|
|
947
|
-
|
|
948
|
-
// Only when the input inside the child form changes, the validation state is propagated
|
|
949
|
-
// changeInputValue(input, "abc");
|
|
950
|
-
input.setAttribute("value", "abc");
|
|
951
|
-
input.dispatchEvent(new Event("change"));
|
|
952
|
-
expect(form.$error.maxlength[0]).toBe(childFormController);
|
|
953
|
-
expect(form.$dirty).toBe(false);
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
it("should use the correct parent when renaming and removing dynamically added forms", async () => {
|
|
957
|
-
scope.formName = "childForm";
|
|
958
|
-
scope.hasChildForm = true;
|
|
959
|
-
|
|
960
|
-
doc = $compile(
|
|
961
|
-
`<div>
|
|
962
|
-
<form name="myForm">
|
|
963
|
-
<div ng-if="hasChildForm">
|
|
964
|
-
<ng-form name="{{formName}}">
|
|
965
|
-
<input name="childformcontrol" ng-maxlength="1" ng-model="value"/>
|
|
966
|
-
</ng-form>
|
|
967
|
-
</div>
|
|
968
|
-
</form>
|
|
969
|
-
<form name="otherForm"></form>
|
|
970
|
-
</div>`,
|
|
971
|
-
)(scope);
|
|
972
|
-
|
|
973
|
-
await wait();
|
|
974
|
-
const form = scope.myForm;
|
|
975
|
-
const childForm = scope.myForm.childForm;
|
|
976
|
-
const otherForm = scope.otherForm;
|
|
977
|
-
|
|
978
|
-
// remove child form and add it to another form
|
|
979
|
-
form.$removeControl(childForm);
|
|
980
|
-
otherForm.$addControl(childForm);
|
|
981
|
-
|
|
982
|
-
expect(form.childForm).toBeUndefined();
|
|
983
|
-
expect(otherForm.childForm).toBe(childForm);
|
|
984
|
-
|
|
985
|
-
// rename the childForm
|
|
986
|
-
scope.formName = "childFormMoved";
|
|
987
|
-
await wait();
|
|
988
|
-
|
|
989
|
-
expect(form.childFormMoved).toBeUndefined();
|
|
990
|
-
expect(otherForm.childForm).toBeUndefined();
|
|
991
|
-
expect(otherForm.childFormMoved).toBe(childForm);
|
|
992
|
-
|
|
993
|
-
scope.hasChildForm = false;
|
|
994
|
-
await wait();
|
|
995
|
-
expect(form.childFormMoved).toBeUndefined();
|
|
996
|
-
expect(otherForm.childFormMoved).toBeDefined();
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
it("should chain nested forms in repeater", async () => {
|
|
1000
|
-
doc = createElementFromHTML(
|
|
1001
|
-
"<ng-form name=parent>" +
|
|
1002
|
-
'<ng-form ng-repeat="f in forms" name=child>' +
|
|
1003
|
-
"<input type=text ng-model=text name=text>" +
|
|
1004
|
-
"</ng-form>" +
|
|
1005
|
-
"</ng-form>",
|
|
1006
|
-
);
|
|
1007
|
-
$compile(doc)(scope);
|
|
1008
|
-
scope.forms = [1];
|
|
1009
|
-
await wait();
|
|
1010
|
-
|
|
1011
|
-
const { parent } = scope;
|
|
1012
|
-
const child = parent.child;
|
|
1013
|
-
const input = child.text;
|
|
1014
|
-
|
|
1015
|
-
expect(parent).toBeDefined();
|
|
1016
|
-
expect(child).toBeDefined();
|
|
1017
|
-
expect(input).toBeDefined();
|
|
1018
|
-
|
|
1019
|
-
input.$setValidity("myRule", false);
|
|
1020
|
-
expect(input.$error.myRule).toEqual(true);
|
|
1021
|
-
expect(child.$error.myRule).toEqual([input]);
|
|
1022
|
-
expect(parent.$error.myRule).toEqual([child]);
|
|
1023
|
-
|
|
1024
|
-
input.$setValidity("myRule", true);
|
|
1025
|
-
expect(parent.$error.myRule).toBeFalsy();
|
|
1026
|
-
expect(child.$error.myRule).toBeFalsy();
|
|
1027
|
-
});
|
|
1028
|
-
});
|
|
1029
|
-
|
|
1030
|
-
describe("validation", () => {
|
|
1031
|
-
beforeEach(() => {
|
|
1032
|
-
doc = $compile(
|
|
1033
|
-
'<form name="form">' +
|
|
1034
|
-
'<input ng-model="name" name="name" store-model-ctrl/>' +
|
|
1035
|
-
"</form>",
|
|
1036
|
-
)(scope);
|
|
1037
|
-
});
|
|
1038
|
-
|
|
1039
|
-
it("should have ng-valid/ng-invalid css class", () => {
|
|
1040
|
-
expect(doc.classList.contains("ng-valid")).toBeTrue();
|
|
1041
|
-
|
|
1042
|
-
control.$setValidity("error", false);
|
|
1043
|
-
expect(doc.classList.contains("ng-invalid")).toBeTrue();
|
|
1044
|
-
expect(doc.classList.contains("ng-valid-error")).toBe(false);
|
|
1045
|
-
expect(doc.classList.contains("ng-invalid-error")).toBe(true);
|
|
1046
|
-
|
|
1047
|
-
control.$setValidity("another", false);
|
|
1048
|
-
expect(doc.classList.contains("ng-valid-error")).toBe(false);
|
|
1049
|
-
expect(doc.classList.contains("ng-invalid-error")).toBe(true);
|
|
1050
|
-
expect(doc.classList.contains("ng-valid-another")).toBe(false);
|
|
1051
|
-
expect(doc.classList.contains("ng-invalid-another")).toBe(true);
|
|
1052
|
-
|
|
1053
|
-
control.$setValidity("error", true);
|
|
1054
|
-
expect(doc.classList.contains("ng-invalid")).toBeTrue();
|
|
1055
|
-
expect(doc.classList.contains("ng-valid-error")).toBe(true);
|
|
1056
|
-
expect(doc.classList.contains("ng-invalid-error")).toBe(false);
|
|
1057
|
-
expect(doc.classList.contains("ng-valid-another")).toBe(false);
|
|
1058
|
-
expect(doc.classList.contains("ng-invalid-another")).toBe(true);
|
|
1059
|
-
|
|
1060
|
-
control.$setValidity("another", true);
|
|
1061
|
-
expect(doc.classList.contains("ng-valid")).toBeTrue();
|
|
1062
|
-
expect(doc.classList.contains("ng-valid-error")).toBe(true);
|
|
1063
|
-
expect(doc.classList.contains("ng-invalid-error")).toBe(false);
|
|
1064
|
-
expect(doc.classList.contains("ng-valid-another")).toBe(true);
|
|
1065
|
-
expect(doc.classList.contains("ng-invalid-another")).toBe(false);
|
|
1066
|
-
|
|
1067
|
-
// validators are skipped, e.g. because of a parser error
|
|
1068
|
-
control.$setValidity("error", null);
|
|
1069
|
-
control.$setValidity("another", null);
|
|
1070
|
-
expect(doc.classList.contains("ng-valid-error")).toBe(false);
|
|
1071
|
-
expect(doc.classList.contains("ng-invalid-error")).toBe(false);
|
|
1072
|
-
expect(doc.classList.contains("ng-valid-another")).toBe(false);
|
|
1073
|
-
expect(doc.classList.contains("ng-invalid-another")).toBe(false);
|
|
1074
|
-
});
|
|
1075
|
-
|
|
1076
|
-
it("should have ng-pristine/ng-dirty css class", async () => {
|
|
1077
|
-
expect(doc.classList.contains("ng-pristine")).toBeTrue();
|
|
1078
|
-
expect(doc.classList.contains("ng-dirty")).toBeFalse();
|
|
1079
|
-
|
|
1080
|
-
control.$setViewValue("");
|
|
1081
|
-
await wait();
|
|
1082
|
-
expect(doc.classList.contains("ng-pristine")).toBeFalse();
|
|
1083
|
-
expect(doc.classList.contains("ng-dirty")).toBeTrue();
|
|
1084
|
-
});
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
|
-
describe("$pending", () => {
|
|
1088
|
-
beforeEach(() => {
|
|
1089
|
-
doc = $compile('<form name="form"></form>')(scope);
|
|
1090
|
-
});
|
|
1091
|
-
|
|
1092
|
-
it("should set valid and invalid to undefined when a validation error state is set as pending", () => {
|
|
1093
|
-
let defer;
|
|
1094
|
-
const form = getCacheData(doc, "$formController");
|
|
1095
|
-
|
|
1096
|
-
const ctrl = {};
|
|
1097
|
-
form.$setValidity("matias", undefined, ctrl);
|
|
1098
|
-
|
|
1099
|
-
expect(form.$valid).toBeUndefined();
|
|
1100
|
-
expect(form.$invalid).toBeUndefined();
|
|
1101
|
-
expect(form.$pending.matias).toEqual([ctrl]);
|
|
1102
|
-
|
|
1103
|
-
form.$setValidity("matias", true, ctrl);
|
|
1104
|
-
|
|
1105
|
-
expect(form.$valid).toBe(true);
|
|
1106
|
-
expect(form.$invalid).toBe(false);
|
|
1107
|
-
expect(form.$pending).toBeUndefined();
|
|
1108
|
-
|
|
1109
|
-
form.$setValidity("matias", false, ctrl);
|
|
1110
|
-
|
|
1111
|
-
expect(form.$valid).toBe(false);
|
|
1112
|
-
expect(form.$invalid).toBe(true);
|
|
1113
|
-
expect(form.$pending).toBeUndefined();
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
|
|
1117
|
-
describe("$setPristine", () => {
|
|
1118
|
-
it("should reset pristine state of form and controls", async () => {
|
|
1119
|
-
doc = $compile(
|
|
1120
|
-
'<form name="testForm">' +
|
|
1121
|
-
'<input ng-model="named1" name="foo">' +
|
|
1122
|
-
'<input ng-model="named2" name="bar">' +
|
|
1123
|
-
"</form>",
|
|
1124
|
-
)(scope);
|
|
1125
|
-
await wait();
|
|
1126
|
-
const form = doc;
|
|
1127
|
-
const formCtrl = scope.testForm;
|
|
1128
|
-
const input1 = form.children[0];
|
|
1129
|
-
const input1Ctrl = getController(input1, "ngModel");
|
|
1130
|
-
const input2 = form.querySelectorAll("input")[1];
|
|
1131
|
-
const input2Ctrl = getController(input2, "ngModel");
|
|
1132
|
-
|
|
1133
|
-
input1Ctrl.$setViewValue("xx");
|
|
1134
|
-
input2Ctrl.$setViewValue("yy");
|
|
1135
|
-
await wait();
|
|
1136
|
-
expect(form.classList.contains("ng-dirty")).toBeTrue();
|
|
1137
|
-
expect(input1.classList.contains("ng-dirty")).toBeTrue();
|
|
1138
|
-
expect(input2.classList.contains("ng-dirty")).toBeTrue();
|
|
1139
|
-
|
|
1140
|
-
formCtrl.$setPristine();
|
|
1141
|
-
expect(form.classList.contains("ng-pristine")).toBeTrue();
|
|
1142
|
-
expect(form.classList.contains("ng-dirty")).toBeFalse();
|
|
1143
|
-
expect(formCtrl.$pristine).toBe(true);
|
|
1144
|
-
expect(formCtrl.$dirty).toBe(false);
|
|
1145
|
-
|
|
1146
|
-
expect(input1.classList.contains("ng-pristine")).toBeTrue();
|
|
1147
|
-
expect(input1Ctrl.$pristine).toBe(true);
|
|
1148
|
-
expect(input1Ctrl.$dirty).toBe(false);
|
|
1149
|
-
expect(input2.classList.contains("ng-pristine")).toBeTrue();
|
|
1150
|
-
expect(input2Ctrl.$pristine).toBe(true);
|
|
1151
|
-
expect(input2Ctrl.$dirty).toBe(false);
|
|
1152
|
-
});
|
|
1153
|
-
|
|
1154
|
-
it("should reset pristine state of anonymous form controls", async () => {
|
|
1155
|
-
doc = $compile(
|
|
1156
|
-
'<form name="testForm">' + '<input ng-model="anonymous">' + "</form>",
|
|
1157
|
-
)(scope);
|
|
1158
|
-
|
|
1159
|
-
const form = doc;
|
|
1160
|
-
const formCtrl = scope.testForm;
|
|
1161
|
-
const input = form.children[0];
|
|
1162
|
-
const inputCtrl = getController(input, "ngModel");
|
|
1163
|
-
|
|
1164
|
-
inputCtrl.$setViewValue("xx");
|
|
1165
|
-
await wait();
|
|
1166
|
-
expect(form.classList.contains("ng-dirty")).toBeTrue();
|
|
1167
|
-
expect(input.classList.contains("ng-dirty")).toBeTrue();
|
|
1168
|
-
|
|
1169
|
-
formCtrl.$setPristine();
|
|
1170
|
-
expect(form.classList.contains("ng-pristine")).toBeTrue();
|
|
1171
|
-
expect(formCtrl.$pristine).toBe(true);
|
|
1172
|
-
expect(formCtrl.$dirty).toBe(false);
|
|
1173
|
-
expect(input.classList.contains("ng-pristine")).toBeTrue();
|
|
1174
|
-
expect(inputCtrl.$pristine).toBe(true);
|
|
1175
|
-
expect(inputCtrl.$dirty).toBe(false);
|
|
1176
|
-
});
|
|
1177
|
-
|
|
1178
|
-
it("should reset pristine state of nested forms", async () => {
|
|
1179
|
-
doc = $compile(
|
|
1180
|
-
'<form name="testForm">' +
|
|
1181
|
-
"<div ng-form>" +
|
|
1182
|
-
'<input ng-model="named" name="foo">' +
|
|
1183
|
-
"</div>" +
|
|
1184
|
-
"</form>",
|
|
1185
|
-
)(scope);
|
|
1186
|
-
await wait();
|
|
1187
|
-
|
|
1188
|
-
const form = doc;
|
|
1189
|
-
const formCtrl = scope.testForm;
|
|
1190
|
-
const nestedForm = form.querySelector("div");
|
|
1191
|
-
assert(nestedForm);
|
|
1192
|
-
const nestedFormCtrl = getController(nestedForm, "form");
|
|
1193
|
-
assert(nestedFormCtrl);
|
|
1194
|
-
const nestedInput = form.children[0].children[0];
|
|
1195
|
-
assert(nestedInput);
|
|
1196
|
-
const nestedInputCtrl = getController(nestedInput, "ngModel");
|
|
1197
|
-
assert(nestedInputCtrl);
|
|
1198
|
-
|
|
1199
|
-
nestedInputCtrl.$setViewValue("xx");
|
|
1200
|
-
await wait();
|
|
1201
|
-
expect(form.classList.contains("ng-dirty")).toBeTrue();
|
|
1202
|
-
expect(nestedForm.classList.contains("ng-dirty")).toBeTrue();
|
|
1203
|
-
expect(nestedInput.classList.contains("ng-dirty")).toBeTrue();
|
|
1204
|
-
|
|
1205
|
-
formCtrl.$setPristine();
|
|
1206
|
-
expect(form.classList.contains("ng-pristine")).toBeTrue();
|
|
1207
|
-
expect(formCtrl.$pristine).toBe(true);
|
|
1208
|
-
expect(formCtrl.$dirty).toBe(false);
|
|
1209
|
-
expect(nestedForm.classList.contains("ng-pristine")).toBeTrue();
|
|
1210
|
-
expect(nestedFormCtrl.$pristine).toBe(true);
|
|
1211
|
-
expect(nestedFormCtrl.$dirty).toBe(false);
|
|
1212
|
-
expect(nestedInput.classList.contains("ng-pristine")).toBeTrue();
|
|
1213
|
-
expect(nestedInputCtrl.$pristine).toBe(true);
|
|
1214
|
-
expect(nestedInputCtrl.$dirty).toBe(false);
|
|
1215
|
-
});
|
|
1216
|
-
});
|
|
1217
|
-
|
|
1218
|
-
describe("$setUntouched", () => {
|
|
1219
|
-
it("should trigger setUntouched on form controls", () => {
|
|
1220
|
-
const form = $compile(
|
|
1221
|
-
'<form name="myForm">' +
|
|
1222
|
-
'<input name="alias" type="text" ng-model="name" />' +
|
|
1223
|
-
"</form>",
|
|
1224
|
-
)(scope);
|
|
1225
|
-
scope.myForm.alias.$setTouched();
|
|
1226
|
-
expect(scope.myForm.alias.$touched).toBe(true);
|
|
1227
|
-
scope.myForm.$setUntouched();
|
|
1228
|
-
expect(scope.myForm.alias.$touched).toBe(false);
|
|
1229
|
-
});
|
|
1230
|
-
|
|
1231
|
-
it("should trigger setUntouched on form controls with nested forms", () => {
|
|
1232
|
-
const form = $compile(
|
|
1233
|
-
'<form name="myForm">' +
|
|
1234
|
-
'<div ng-form name="childForm">' +
|
|
1235
|
-
'<input name="alias" type="text" ng-model="name" />' +
|
|
1236
|
-
"</div>" +
|
|
1237
|
-
"</form>",
|
|
1238
|
-
)(scope);
|
|
1239
|
-
scope.myForm.childForm.alias.$setTouched();
|
|
1240
|
-
expect(scope.myForm.childForm.alias.$touched).toBe(true);
|
|
1241
|
-
scope.myForm.$setUntouched();
|
|
1242
|
-
expect(scope.myForm.childForm.alias.$touched).toBe(false);
|
|
1243
|
-
});
|
|
1244
|
-
});
|
|
1245
|
-
|
|
1246
|
-
describe("$getControls", () => {
|
|
1247
|
-
it("should return an empty array if the controller has no controls", () => {
|
|
1248
|
-
doc = $compile('<form name="testForm"></form>')(scope);
|
|
1249
|
-
|
|
1250
|
-
const formCtrl = scope.testForm;
|
|
1251
|
-
|
|
1252
|
-
expect(formCtrl.$getControls()).toEqual([]);
|
|
1253
|
-
});
|
|
1254
|
-
|
|
1255
|
-
it("should return a shallow copy of the form controls", async () => {
|
|
1256
|
-
doc = $compile(
|
|
1257
|
-
'<form name="testForm">' +
|
|
1258
|
-
'<input ng-model="named" name="foo">' +
|
|
1259
|
-
"<div ng-form>" +
|
|
1260
|
-
'<input ng-model="named" name="foo">' +
|
|
1261
|
-
"</div>" +
|
|
1262
|
-
"</form>",
|
|
1263
|
-
)(scope);
|
|
1264
|
-
await wait();
|
|
1265
|
-
|
|
1266
|
-
const form = doc;
|
|
1267
|
-
const formCtrl = scope.testForm;
|
|
1268
|
-
const formInput = form.children[0];
|
|
1269
|
-
const formInputCtrl = getController(formInput, "ngModel");
|
|
1270
|
-
const nestedForm = form.querySelector("div");
|
|
1271
|
-
const nestedFormCtrl = getController(nestedForm, "form");
|
|
1272
|
-
const nestedInput = nestedForm.children[0];
|
|
1273
|
-
const nestedInputCtrl = getController(nestedInput, "ngModel");
|
|
1274
|
-
|
|
1275
|
-
const controls = formCtrl.$getControls();
|
|
1276
|
-
|
|
1277
|
-
expect(controls).not.toBe(formCtrl.$$controls);
|
|
1278
|
-
|
|
1279
|
-
controls.push("something");
|
|
1280
|
-
expect(formCtrl.$$controls).not.toContain("something");
|
|
1281
|
-
|
|
1282
|
-
expect(controls[0]).toBe(formInputCtrl);
|
|
1283
|
-
expect(controls[1]).toBe(nestedFormCtrl);
|
|
1284
|
-
|
|
1285
|
-
const nestedControls = controls[1].$getControls();
|
|
1286
|
-
|
|
1287
|
-
expect(nestedControls[0]).toBe(nestedInputCtrl);
|
|
1288
|
-
});
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
it("should rename nested form controls when interpolated name changes", async () => {
|
|
1292
|
-
scope.idA = "A";
|
|
1293
|
-
scope.idB = "X";
|
|
1294
|
-
|
|
1295
|
-
doc = $compile(
|
|
1296
|
-
'<form name="form">' +
|
|
1297
|
-
'<div ng-form="nested{{idA}}">' +
|
|
1298
|
-
'<div ng-form name="nested{{idB}}"' +
|
|
1299
|
-
"</div>" +
|
|
1300
|
-
"</div>" +
|
|
1301
|
-
"</form>",
|
|
1302
|
-
)(scope);
|
|
1303
|
-
await wait();
|
|
1304
|
-
const formA = scope.form.nestedA;
|
|
1305
|
-
expect(formA).toBeDefined();
|
|
1306
|
-
expect(formA.$name).toBe("nestedA");
|
|
1307
|
-
|
|
1308
|
-
const formX = formA.nestedX;
|
|
1309
|
-
expect(formX).toBeDefined();
|
|
1310
|
-
expect(formX.$name).toBe("nestedX");
|
|
1311
|
-
|
|
1312
|
-
scope.idA = "B";
|
|
1313
|
-
scope.idB = "Y";
|
|
1314
|
-
await wait();
|
|
1315
|
-
expect(scope.form.nestedA).toBeUndefined();
|
|
1316
|
-
expect(scope.form.nestedB).toBe(formA);
|
|
1317
|
-
expect(formA.nestedX).toBeUndefined();
|
|
1318
|
-
expect(formA.nestedY).toBe(formX);
|
|
1319
|
-
});
|
|
1320
|
-
|
|
1321
|
-
it("should rename forms with no parent when interpolated name changes", async () => {
|
|
1322
|
-
const element = $compile('<form name="name{{nameID}}"></form>')(scope);
|
|
1323
|
-
const element2 = $compile('<div ng-form="ngform{{nameID}}"></div>')(scope);
|
|
1324
|
-
await wait();
|
|
1325
|
-
scope.nameID = "A";
|
|
1326
|
-
await wait();
|
|
1327
|
-
const form = getController(element, "form");
|
|
1328
|
-
const form2 = getController(element2, "form");
|
|
1329
|
-
expect(scope.nameA).toBe(form);
|
|
1330
|
-
expect(scope.ngformA).toBe(form2);
|
|
1331
|
-
expect(form.$name).toBe("nameA");
|
|
1332
|
-
expect(form2.$name).toBe("ngformA");
|
|
1333
|
-
|
|
1334
|
-
scope.nameID = "B";
|
|
1335
|
-
await wait();
|
|
1336
|
-
expect(scope.nameA).toBeUndefined();
|
|
1337
|
-
expect(scope.ngformA).toBeUndefined();
|
|
1338
|
-
expect(scope.nameB).toBe(form);
|
|
1339
|
-
expect(scope.ngformB).toBe(form2);
|
|
1340
|
-
expect(form.$name).toBe("nameB");
|
|
1341
|
-
expect(form2.$name).toBe("ngformB");
|
|
1342
|
-
});
|
|
1343
|
-
|
|
1344
|
-
it("should rename forms with an initially blank name", async () => {
|
|
1345
|
-
const element = $compile('<form name="{{name}}"></form>')(scope);
|
|
1346
|
-
await wait();
|
|
1347
|
-
const form = getController(element, "form");
|
|
1348
|
-
expect(scope[""]).toBe(form);
|
|
1349
|
-
expect(form.$name).toBe("");
|
|
1350
|
-
scope.name = "foo";
|
|
1351
|
-
await wait();
|
|
1352
|
-
|
|
1353
|
-
expect(scope.foo).toBe(form);
|
|
1354
|
-
expect(form.$name).toBe("foo");
|
|
1355
|
-
expect(scope.foo).toBe(form);
|
|
1356
|
-
});
|
|
1357
|
-
|
|
1358
|
-
describe("$setSubmitted", () => {
|
|
1359
|
-
beforeEach(async () => {
|
|
1360
|
-
doc = $compile(
|
|
1361
|
-
'<form name="form" ng-submit="submitted = true">' +
|
|
1362
|
-
'<input type="text" ng-model="name" required />' +
|
|
1363
|
-
'<input type="submit" />' +
|
|
1364
|
-
"</form>",
|
|
1365
|
-
)(scope);
|
|
1366
|
-
await wait();
|
|
1367
|
-
});
|
|
1368
|
-
|
|
1369
|
-
it("should not init in submitted state", () => {
|
|
1370
|
-
expect(scope.form.$submitted).toBe(false);
|
|
1371
|
-
});
|
|
1372
|
-
|
|
1373
|
-
it("should be in submitted state when submitted", () => {
|
|
1374
|
-
// browserTrigger(doc, "submit");
|
|
1375
|
-
doc.dispatchEvent(new Event("submit"));
|
|
1376
|
-
expect(scope.form.$submitted).toBe(true);
|
|
1377
|
-
});
|
|
1378
|
-
|
|
1379
|
-
it("should revert submitted back to false when $setPristine is called on the form", () => {
|
|
1380
|
-
scope.form.$submitted = true;
|
|
1381
|
-
scope.form.$setPristine();
|
|
1382
|
-
expect(scope.form.$submitted).toBe(false);
|
|
1383
|
-
});
|
|
1384
|
-
});
|
|
1385
|
-
|
|
1386
|
-
// TODO After animations
|
|
1387
|
-
xdescribe("form animations", () => {
|
|
1388
|
-
function assertValidAnimation(
|
|
1389
|
-
animation,
|
|
1390
|
-
event,
|
|
1391
|
-
classNameAdded,
|
|
1392
|
-
classNameRemoved,
|
|
1393
|
-
) {
|
|
1394
|
-
expect(animation.event).toBe(event);
|
|
1395
|
-
expect(animation.args[1]).toBe(classNameAdded);
|
|
1396
|
-
expect(animation.args[2]).toBe(classNameRemoved);
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
let form;
|
|
1400
|
-
let $animate;
|
|
1401
|
-
let myModule;
|
|
1402
|
-
|
|
1403
|
-
beforeEach(() => {
|
|
1404
|
-
let dummy = document.getElementById("app");
|
|
1405
|
-
doc = '<form name="myForm"></form>';
|
|
1406
|
-
dummy.append(doc);
|
|
1407
|
-
dealoc(document.getElementById("app"));
|
|
1408
|
-
let angular = new Angular();
|
|
1409
|
-
window.angular = new Angular();
|
|
1410
|
-
myModule = window.angular.module("myModule", []);
|
|
1411
|
-
|
|
1412
|
-
injector = angular.bootstrap(dummy, ["myModule"]);
|
|
1413
|
-
injector.invoke((_$compile_, $rootScope, _$animate_) => {
|
|
1414
|
-
$compile = _$compile_;
|
|
1415
|
-
scope = $rootScope.$new();
|
|
1416
|
-
$animate = _$animate_;
|
|
1417
|
-
});
|
|
1418
|
-
form = scope.myForm;
|
|
1419
|
-
});
|
|
1420
|
-
|
|
1421
|
-
afterEach(() => {
|
|
1422
|
-
dealoc(doc);
|
|
1423
|
-
dealoc(dummy);
|
|
1424
|
-
document.getElementById("app").innerHTML = "";
|
|
1425
|
-
});
|
|
1426
|
-
|
|
1427
|
-
it("should trigger an animation when invalid", (done) => {
|
|
1428
|
-
form.$setValidity("required", false);
|
|
1429
|
-
setTimeout(() => {
|
|
1430
|
-
// assertValidAnimation($animate.queue[0], "removeClass", "ng-valid");
|
|
1431
|
-
// assertValidAnimation($animate.queue[1], "addClass", "ng-invalid");
|
|
1432
|
-
// assertValidAnimation($animate.queue[2], "addClass", "ng-invalid-required");
|
|
1433
|
-
expect(doc.classList.contains("ng-valid")).toBeTrue();
|
|
1434
|
-
expect(doc.classList.contains("ng-invalid-add")).toBeTrue();
|
|
1435
|
-
expect(doc.classList.contains("ng-invalid-required-add")).toBeTrue();
|
|
1436
|
-
done();
|
|
1437
|
-
}, 100);
|
|
1438
|
-
});
|
|
1439
|
-
|
|
1440
|
-
it("should trigger an animation when valid", (done) => {
|
|
1441
|
-
form.$setValidity("required", false);
|
|
1442
|
-
|
|
1443
|
-
form.$setValidity("required", true);
|
|
1444
|
-
|
|
1445
|
-
setTimeout(() => {
|
|
1446
|
-
// assertValidAnimation($animate.queue[0], "addClass", "ng-valid");
|
|
1447
|
-
// assertValidAnimation($animate.queue[1], "removeClass", "ng-invalid");
|
|
1448
|
-
// assertValidAnimation($animate.queue[2], "addClass", "ng-valid-required");
|
|
1449
|
-
expect(doc.classList.contains("ng-valid")).toBeTrue();
|
|
1450
|
-
expect(doc.classList.contains("ng-invalid-add")).toBeTrue();
|
|
1451
|
-
expect(doc.classList.contains("ng-invalid-required-add")).toBeTrue();
|
|
1452
|
-
done();
|
|
1453
|
-
}, 100);
|
|
1454
|
-
});
|
|
1455
|
-
|
|
1456
|
-
it("should trigger an animation when dirty", (done) => {
|
|
1457
|
-
form.$setDirty();
|
|
1458
|
-
setTimeout(() => {
|
|
1459
|
-
// assertValidAnimation($animate.queue[0], "removeClass", "ng-pristine");
|
|
1460
|
-
// assertValidAnimation($animate.queue[1], "addClass", "ng-dirty");
|
|
1461
|
-
expect(doc.classList.contains("ng-pristine")).toBeTrue();
|
|
1462
|
-
expect(doc.classList.contains("ng-dirty-add")).toBeTrue();
|
|
1463
|
-
done();
|
|
1464
|
-
}, 100);
|
|
1465
|
-
});
|
|
1466
|
-
|
|
1467
|
-
it("should trigger an animation when pristine", (done) => {
|
|
1468
|
-
form.$setDirty();
|
|
1469
|
-
form.$setPristine();
|
|
1470
|
-
setTimeout(() => {
|
|
1471
|
-
// assertValidAnimation($animate.queue[0], "removeClass", "ng-pristine");
|
|
1472
|
-
// assertValidAnimation($animate.queue[1], "addClass", "ng-dirty");
|
|
1473
|
-
expect(doc.classList.contains("ng-pristine")).toBeTrue();
|
|
1474
|
-
expect(doc.classList.contains("ng-dirty-add")).toBeTrue();
|
|
1475
|
-
done();
|
|
1476
|
-
}, 100);
|
|
1477
|
-
});
|
|
1478
|
-
|
|
1479
|
-
it("should trigger custom errors as addClass/removeClass when invalid/valid", (done) => {
|
|
1480
|
-
form.$setValidity("custom-error", false);
|
|
1481
|
-
|
|
1482
|
-
setTimeout(() => {
|
|
1483
|
-
// assertValidAnimation($animate.queue[0], "removeClass", "ng-valid");
|
|
1484
|
-
// assertValidAnimation($animate.queue[1], "addClass", "ng-invalid");
|
|
1485
|
-
// assertValidAnimation(
|
|
1486
|
-
// $animate.queue[2],
|
|
1487
|
-
// "addClass",
|
|
1488
|
-
// "ng-invalid-custom-error",
|
|
1489
|
-
// );
|
|
1490
|
-
expect(doc.classList.contains("ng-valid")).toBeTrue();
|
|
1491
|
-
expect(doc.classList.contains("ng-invalid-add")).toBeTrue();
|
|
1492
|
-
expect(
|
|
1493
|
-
doc.classList.contains("ng-invalid-custom-error-add"),
|
|
1494
|
-
).toBeTrue();
|
|
1495
|
-
}, 100);
|
|
1496
|
-
|
|
1497
|
-
// $animate.queue = [];
|
|
1498
|
-
form.$setValidity("custom-error", true);
|
|
1499
|
-
|
|
1500
|
-
setTimeout(() => {
|
|
1501
|
-
// assertValidAnimation($animate.queue[0], "removeClass", "ng-valid");
|
|
1502
|
-
// assertValidAnimation($animate.queue[1], "addClass", "ng-invalid");
|
|
1503
|
-
// assertValidAnimation(
|
|
1504
|
-
// $animate.queue[2],
|
|
1505
|
-
// "addClass",
|
|
1506
|
-
// "ng-invalid-custom-error",
|
|
1507
|
-
// );
|
|
1508
|
-
expect(doc.classList.contains("ng-valid")).toBeTrue();
|
|
1509
|
-
expect(doc.classList.contains("ng-invalid-add")).toBeTrue();
|
|
1510
|
-
expect(doc.classList.contains("ng-valid-custom-error-add")).toBeTrue();
|
|
1511
|
-
done();
|
|
1512
|
-
}, 300);
|
|
1513
|
-
});
|
|
1514
|
-
});
|
|
1515
|
-
});
|