@angular-wave/angular.ts 0.7.8 → 0.8.1
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/{loader.d.ts → angular.d.ts} +3 -3
- package/@types/core/di/ng-module.d.ts +61 -25
- package/@types/core/parse/parse.d.ts +6 -7
- package/@types/directive/bind/bind.d.ts +2 -1
- package/@types/index.d.ts +1 -1
- package/@types/interface.d.ts +4 -2
- package/@types/{public.d.ts → ng.d.ts} +2 -2
- package/@types/router/directives/state-directives.d.ts +2 -2
- package/@types/router/directives/view-directive.d.ts +1 -1
- package/@types/router/params/param-type.d.ts +0 -1
- package/@types/router/path/path-utils.d.ts +8 -11
- package/@types/router/{globals.d.ts → router.d.ts} +2 -2
- package/@types/router/state/interface.d.ts +1 -1
- package/@types/router/state/state-object.d.ts +1 -1
- package/@types/router/state/state-registry.d.ts +2 -2
- package/@types/router/state/state-service.d.ts +14 -16
- package/@types/router/state-filters.d.ts +24 -2
- package/@types/router/transition/transition-service.d.ts +3 -3
- package/@types/router/transition/transition.d.ts +16 -19
- package/@types/router/url/url-matcher.d.ts +3 -4
- package/@types/router/url/url-rule.d.ts +14 -4
- package/@types/router/url/url-rules.d.ts +26 -6
- package/@types/router/url/url-service.d.ts +28 -38
- package/@types/services/http/http.d.ts +48 -1
- package/@types/services/http-backend/http-backend.d.ts +48 -35
- package/@types/services/location/interface.d.ts +55 -0
- package/@types/services/location/location.d.ts +225 -252
- package/@types/shared/common.d.ts +0 -2
- package/@types/shared/hof.d.ts +0 -6
- package/@types/shared/interface.d.ts +0 -4
- package/@types/{router/common → shared}/queue.d.ts +2 -2
- package/@types/shared/url-utils/interface.d.ts +0 -1
- package/@types/shared/url-utils/url-utils.d.ts +0 -5
- package/@types/shared/utils.d.ts +29 -6
- package/CHANGELOG.md +0 -72
- package/CONTRIBUTING.md +0 -1
- package/DEVELOPERS.md +0 -1
- package/Makefile +6 -3
- package/TRIAGING.md +0 -1
- package/dist/angular-ts.esm.js +1048 -1150
- package/dist/angular-ts.umd.js +1048 -1150
- package/dist/angular-ts.umd.min.js +1 -1
- package/docs/assets/scss/index.scss +23 -0
- package/docs/content/_index.md +9 -8
- package/docs/content/docs/_index.md +1 -1
- package/docs/content/docs/directive/app.md +1 -1
- package/docs/content/docs/directive/bind.md +1 -1
- package/docs/content/docs/directive/blur.md +1 -1
- package/docs/content/docs/directive/channel.md +2 -2
- package/docs/content/docs/directive/class-even.md +1 -1
- package/docs/content/docs/directive/class-odd.md +1 -1
- package/docs/content/docs/directive/class.md +1 -1
- package/docs/content/docs/directive/click.md +1 -1
- package/docs/content/docs/directive/copy.md +1 -1
- package/docs/content/docs/directive/cut.md +1 -1
- package/docs/content/docs/directive/dblclick.md +1 -1
- package/docs/content/docs/directive/focus.md +1 -1
- package/docs/content/docs/directive/get.md +3 -3
- package/docs/content/docs/directive/keydown.md +1 -1
- package/docs/content/docs/directive/keyup.md +1 -1
- package/docs/content/docs/directive/load.md +1 -1
- package/docs/content/docs/directive/mousedown.md +1 -1
- package/docs/content/docs/directive/mouseenter.md +1 -1
- package/docs/content/docs/directive/mouseleave.md +1 -1
- package/docs/content/docs/directive/mousemove.md +1 -1
- package/docs/content/docs/directive/mouseout.md +1 -1
- package/docs/content/docs/directive/mouseover.md +1 -1
- package/docs/content/docs/directive/mouseup.md +1 -1
- package/docs/content/docs/directive/non-bindable.md +28 -0
- package/docs/content/docs/provider/locationProvider.md +26 -0
- package/docs/content/docs/provider/templateCacheProvider.md +2 -2
- package/docs/content/docs/service/location.md +57 -0
- package/docs/content/docs/service/url.md +5 -0
- package/docs/layouts/partials/hooks/head-end.html +1 -1
- package/docs/layouts/shortcodes/version.html +1 -0
- package/docs/static/examples/counter/counter-test.html +0 -4
- package/docs/static/examples/eventbus/eventbus-test.html +0 -4
- package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +13 -0
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +3 -0
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +11 -0
- package/docs/static/typedoc/assets/hierarchy.js +1 -1
- package/docs/static/typedoc/assets/highlight.css +6 -6
- package/docs/static/typedoc/assets/navigation.js +1 -1
- package/docs/static/typedoc/assets/search.js +1 -1
- package/docs/static/typedoc/classes/Location.html +55 -0
- package/docs/static/typedoc/classes/LocationProvider.html +20 -0
- package/docs/static/typedoc/classes/NgModule.html +3 -3
- package/docs/static/typedoc/index.html +1 -1
- package/docs/static/typedoc/interfaces/DefaultPorts.html +5 -0
- package/docs/static/typedoc/interfaces/Html5Mode.html +23 -0
- package/docs/static/typedoc/interfaces/Provider.html +2 -1
- package/docs/static/typedoc/interfaces/UrlParts.html +9 -0
- package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
- package/docs/static/typedoc/types/Expression.html +1 -1
- package/docs/static/typedoc/types/Injectable.html +4 -1
- package/docs/static/typedoc/types/InjectableFactory.html +1 -4
- package/docs/static/typedoc/types/UrlChangeListener.html +5 -0
- package/docs/static/version.js +13 -0
- package/docs/test-results/.last-run.json +4 -0
- package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +50 -0
- package/package.json +2 -2
- package/src/{loader.js → angular.js} +11 -11
- package/src/angular.spec.js +189 -21
- package/src/animations/animate-css.js +17 -18
- package/src/animations/animate.spec.js +1 -1
- package/src/animations/shared.js +2 -3
- package/src/binding.spec.js +1 -1
- package/src/core/compile/compile.js +4 -7
- package/src/core/compile/compile.spec.js +1 -1
- package/src/core/controller/controller.spec.js +1 -1
- package/src/core/controller/controller.test.js +1 -0
- package/src/core/di/injector.js +7 -8
- package/src/core/di/injector.spec.js +2 -2
- package/src/core/di/injector.test.js +2 -2
- package/src/core/di/internal-injector.js +3 -6
- package/src/core/di/ng-module.js +26 -21
- package/src/core/filter/filter.js +1 -1
- package/src/core/filter/filter.spec.js +1 -1
- package/src/core/filter/filter.test.js +1 -0
- package/src/core/interpolate/interpolate.js +4 -6
- package/src/core/interpolate/interpolate.spec.js +1 -1
- package/src/core/interpolate/interpolate.test.js +1 -0
- package/src/core/parse/ast/ast.spec.js +1 -1
- package/src/core/parse/ast/ast.test.js +1 -1
- package/src/core/parse/lexer/lexer.spec.js +1 -1
- package/src/core/parse/parse.js +150 -146
- package/src/core/parse/parse.spec.js +46 -46
- package/src/core/prop.spec.js +1 -1
- package/src/core/root-element.spec.js +1 -1
- package/src/core/scope/scope.js +10 -11
- package/src/core/scope/scope.spec.js +3 -4
- package/src/directive/aria/aria.spec.js +1 -1
- package/src/directive/aria/aria.test.js +1 -0
- package/src/directive/attrs/attrs.spec.js +1 -1
- package/src/directive/attrs/attrs.test.js +1 -0
- package/src/directive/attrs/boolean.spec.js +1 -1
- package/src/directive/attrs/boolean.test.js +1 -0
- package/src/directive/attrs/element-style.spec.js +1 -1
- package/src/directive/attrs/element-style.test.js +1 -0
- package/src/directive/attrs/src.spec.js +1 -1
- package/src/directive/attrs/src.test.js +1 -0
- package/src/directive/bind/bind-html.spec.js +1 -1
- package/src/directive/bind/bind.js +1 -0
- package/src/directive/bind/bind.spec.js +1 -1
- package/src/directive/bind/bind.test.js +1 -0
- package/src/directive/channel/channel.spec.js +1 -1
- package/src/directive/channel/channel.test.js +1 -0
- package/src/directive/class/class.spec.js +1 -1
- package/src/directive/class/class.test.js +1 -0
- package/src/directive/cloak/cloak.spec.js +1 -1
- package/src/directive/cloak/cloak.test.js +1 -0
- package/src/directive/controller/controller.spec.js +1 -1
- package/src/directive/controller/controller.test.js +1 -0
- package/src/directive/events/click.spec.js +1 -1
- package/src/directive/events/event.spec.js +6 -6
- package/src/directive/events/events.test.js +1 -0
- package/src/directive/form/form.js +8 -5
- package/src/directive/form/form.spec.js +1 -1
- package/src/directive/form/form.test.js +1 -0
- package/src/directive/http/delete.spec.js +1 -1
- package/src/directive/http/form-test.html +18 -0
- package/src/directive/http/get.spec.js +1 -1
- package/src/directive/http/http.js +12 -3
- package/src/directive/http/post.spec.js +504 -9
- package/src/directive/http/put.spec.js +1 -1
- package/src/directive/if/if.spec.js +1 -1
- package/src/directive/include/include.spec.js +1 -1
- package/src/directive/init/init.spec.js +1 -1
- package/src/directive/init/init.test.js +1 -0
- package/src/directive/input/input.js +13 -15
- package/src/directive/input/input.spec.js +1 -2
- package/src/directive/input/input.test.js +1 -0
- package/src/directive/messages/messages.md +0 -4
- package/src/directive/messages/messages.spec.js +1 -1
- package/src/directive/messages/messages.test.js +1 -0
- package/src/directive/model/model.js +13 -13
- package/src/directive/model/model.spec.js +1 -1
- package/src/directive/model/model.test.js +1 -0
- package/src/directive/model-options/model-option.test.js +1 -0
- package/src/directive/model-options/model-options.js +1 -1
- package/src/directive/model-options/model-options.spec.js +1 -1
- package/src/directive/non-bindable/non-bindable.spec.js +1 -1
- package/src/directive/non-bindable/non-bindable.test.js +1 -0
- package/src/directive/observe/observe.spec.js +1 -1
- package/src/directive/observe/observe.test.js +1 -0
- package/src/directive/on/on.spec.js +1 -1
- package/src/directive/on/on.test.js +1 -0
- package/src/directive/options/options.spec.js +1 -1
- package/src/directive/options/options.test.js +1 -0
- package/src/directive/ref/href.spec.js +1 -1
- package/src/directive/ref/href.test.js +2 -0
- package/src/directive/ref/ref.spec.js +1 -1
- package/src/directive/repeat/repeat.js +1 -1
- package/src/directive/repeat/repeat.spec.js +2 -3
- package/src/directive/repeat/repeat.test.js +1 -0
- package/src/directive/script/script.spec.js +1 -1
- package/src/directive/script/script.test.js +1 -0
- package/src/directive/select/select.js +1 -1
- package/src/directive/select/select.spec.js +1 -1
- package/src/directive/select/select.test.js +1 -0
- package/src/directive/setter/setter.spec.js +1 -1
- package/src/directive/setter/setter.test.js +1 -0
- package/src/directive/show-hide/show-hide.spec.js +1 -1
- package/src/directive/show-hide/show-hide.test.js +1 -0
- package/src/directive/style/style.spec.js +1 -1
- package/src/directive/style/style.test.js +1 -0
- package/src/directive/switch/switch.spec.js +1 -1
- package/src/directive/switch/switch.test.js +1 -0
- package/src/directive/validators/validators.js +82 -84
- package/src/directive/validators/validators.spec.js +5 -4
- package/src/directive/validators/validators.test.js +1 -0
- package/src/filters/filter.spec.js +1 -1
- package/src/filters/filters.spec.js +1 -1
- package/src/filters/limit-to.js +2 -3
- package/src/filters/limit-to.spec.js +1 -1
- package/src/filters/order-by.spec.js +1 -1
- package/src/index.js +1 -1
- package/src/injection-tokens.js +7 -3
- package/src/interface.ts +4 -3
- package/src/loader.md +0 -155
- package/src/{public.js → ng.js} +11 -12
- package/src/{public.spec.js → ng.spec.js} +2 -2
- package/src/router/directives/state-directives.js +5 -5
- package/src/router/directives/state-directives.spec.js +8 -7
- package/src/router/directives/view-directive.js +7 -13
- package/src/router/directives/view-directive.spec.js +22 -23
- package/src/router/{common/common.html → glob/glob.html} +2 -3
- package/src/router/{common/common.test.js → glob/glob.test.js} +2 -1
- package/src/router/params/param-type.js +0 -1
- package/src/router/params/param.js +1 -1
- package/src/router/path/path-utils.js +5 -0
- package/src/router/router-test-hashbang.html +45 -0
- package/src/router/{globals.js → router.js} +2 -2
- package/src/router/services.spec.js +8 -9
- package/src/router/state/interface.ts +1 -1
- package/src/router/state/state-builder.js +3 -3
- package/src/router/state/state-builder.spec.js +1 -1
- package/src/router/state/state-object.js +1 -1
- package/src/router/state/state-registry.js +4 -4
- package/src/router/state/state-service.js +14 -14
- package/src/router/state/state.spec.js +23 -22
- package/src/router/state/state.test.js +1 -0
- package/src/router/state/views.js +1 -1
- package/src/router/state-filter.spec.js +1 -1
- package/src/router/state-filters.js +13 -9
- package/src/router/template-factory.js +5 -4
- package/src/router/template-factory.spec.js +7 -7
- package/src/router/transition/hook-registry.js +1 -1
- package/src/router/transition/transition-service.js +7 -6
- package/src/router/transition/transition.js +6 -6
- package/src/router/url/url-matcher.js +12 -14
- package/src/router/url/url-rule.js +8 -2
- package/src/router/url/url-rules.js +8 -5
- package/src/router/url/url-service.js +80 -76
- package/src/router/url/url-service.spec.js +61 -78
- package/src/router/url/url.test.js +1 -0
- package/src/router/view/view.js +4 -5
- package/src/router/view/view.spec.js +10 -12
- package/src/router/view/view.test.js +1 -0
- package/src/router/view-hook.spec.js +1 -1
- package/src/router/view-scroll.js +3 -1
- package/src/router/view-scroll.spec.js +12 -12
- package/src/services/anchor-scroll.html +2 -2
- package/src/services/anchor-scroll.js +5 -4
- package/src/services/http/http.js +9 -4
- package/src/services/http/http.spec.js +2 -7
- package/src/services/http/template-request.spec.js +1 -1
- package/src/services/http-backend/http-backend.js +51 -77
- package/src/services/http-backend/http-backend.spec.js +1 -2
- package/src/services/http-backend/http-backend.test.js +1 -0
- package/src/services/location/interface.ts +62 -0
- package/src/services/location/location.js +439 -519
- package/src/services/location/location.spec.js +915 -530
- package/src/services/location/location.test.js +2 -2
- package/src/services/log/log.spec.js +1 -1
- package/src/services/log/log.test.js +1 -0
- package/src/services/pubsub/pubsub.spec.js +1 -1
- package/src/services/sce/sce.js +5 -7
- package/src/services/sce/sce.md +2 -2
- package/src/services/sce/sce.spec.js +1 -1
- package/src/services/template-cache/template-cache.spec.js +1 -1
- package/src/services/template-cache/template-cache.test.js +1 -0
- package/src/shared/common.js +5 -10
- package/src/shared/common.spec.js +1 -1
- package/src/shared/hof.js +0 -14
- package/src/shared/interface.ts +0 -4
- package/src/{router/common → shared}/queue.js +7 -7
- package/src/shared/shared.html +1 -0
- package/src/shared/shared.test.js +1 -0
- package/src/shared/url-utils/interface.ts +0 -2
- package/src/shared/url-utils/url-utils.js +6 -30
- package/src/shared/url-utils/url-utils.spec.js +10 -9
- package/src/shared/utils.js +32 -9
- package/src/shared/utils.spec.js +35 -1
- package/src/src.html +1 -2
- package/typedoc.json +0 -1
- package/utils/express.js +27 -1
- package/utils/version.cjs +23 -0
- package/@types/router/state-provider.d.ts +0 -123
- package/src/directive/non-bindable/non-bindable.md +0 -17
- package/src/loader.spec.js +0 -169
- package/src/router/state-provider.js +0 -146
- package/src/services/location/location.md +0 -114
- package/src/shared/url-utils/url-utils.md +0 -46
- /package/@types/router/{common → glob}/glob.d.ts +0 -0
- /package/src/router/{common → glob}/glob.js +0 -0
- /package/src/router/{common → glob}/glob.spec.js +0 -0
- /package/src/{router/common → shared}/queue.spec.js +0 -0
package/src/core/parse/parse.js
CHANGED
|
@@ -3,173 +3,177 @@ import { PURITY_RELATIVE } from "./interpreter.js";
|
|
|
3
3
|
import { Lexer } from "./lexer/lexer.js";
|
|
4
4
|
import { Parser } from "./parser/parser.js";
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Allows defining the set of characters that are allowed in AngularTS expressions. The function
|
|
17
|
-
* `identifierStart` will get called to know if a given character is a valid character to be the
|
|
18
|
-
* first character for an identifier. The function `identifierContinue` will get called to know if
|
|
19
|
-
* a given character is a valid character to be a follow-up identifier character. The functions
|
|
20
|
-
* `identifierStart` and `identifierContinue` will receive as arguments the single character to be
|
|
21
|
-
* identifier and the character code point. These arguments will be `string` and `numeric`. Keep in
|
|
22
|
-
* mind that the `string` parameter can be two characters long depending on the character
|
|
23
|
-
* representation. It is expected for the function to return `true` or `false`, whether that
|
|
24
|
-
* character is allowed or not.
|
|
25
|
-
*
|
|
26
|
-
* Since this function will be called extensively, keep the implementation of these functions fast,
|
|
27
|
-
* as the performance of these functions have a direct impact on the expressions parsing speed.
|
|
28
|
-
*
|
|
29
|
-
* @param {function(any):boolean} [identifierStart] The function that will decide whether the given character is
|
|
30
|
-
* a valid identifier start character.
|
|
31
|
-
* @param {function(any):boolean} [identifierContinue] The function that will decide whether the given character is
|
|
32
|
-
* a valid identifier continue character.
|
|
33
|
-
* @returns {ParseProvider}
|
|
34
|
-
*/
|
|
35
|
-
this.setIdentifierFns = function (identifierStart, identifierContinue) {
|
|
36
|
-
identStart = identifierStart;
|
|
37
|
-
identContinue = identifierContinue;
|
|
38
|
-
return this;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
this.$get = [
|
|
42
|
-
"$filter",
|
|
6
|
+
export class ParseProvider {
|
|
7
|
+
constructor() {
|
|
8
|
+
const cache = Object.create(null);
|
|
9
|
+
|
|
10
|
+
/** @type {function(any):boolean?} */
|
|
11
|
+
let identStart;
|
|
12
|
+
|
|
13
|
+
/** @type {function(any):boolean?} */
|
|
14
|
+
let identContinue;
|
|
15
|
+
|
|
43
16
|
/**
|
|
17
|
+
* Allows defining the set of characters that are allowed in AngularTS expressions. The function
|
|
18
|
+
* `identifierStart` will get called to know if a given character is a valid character to be the
|
|
19
|
+
* first character for an identifier. The function `identifierContinue` will get called to know if
|
|
20
|
+
* a given character is a valid character to be a follow-up identifier character. The functions
|
|
21
|
+
* `identifierStart` and `identifierContinue` will receive as arguments the single character to be
|
|
22
|
+
* identifier and the character code point. These arguments will be `string` and `numeric`. Keep in
|
|
23
|
+
* mind that the `string` parameter can be two characters long depending on the character
|
|
24
|
+
* representation. It is expected for the function to return `true` or `false`, whether that
|
|
25
|
+
* character is allowed or not.
|
|
44
26
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
27
|
+
* Since this function will be called extensively, keep the implementation of these functions fast,
|
|
28
|
+
* as the performance of these functions have a direct impact on the expressions parsing speed.
|
|
29
|
+
*
|
|
30
|
+
* @param {function(any):boolean} [identifierStart] The function that will decide whether the given character is
|
|
31
|
+
* a valid identifier start character.
|
|
32
|
+
* @param {function(any):boolean} [identifierContinue] The function that will decide whether the given character is
|
|
33
|
+
* a valid identifier continue character.
|
|
34
|
+
* @returns {ParseProvider}
|
|
47
35
|
*/
|
|
48
|
-
function (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
this.setIdentifierFns = function (identifierStart, identifierContinue) {
|
|
37
|
+
identStart = identifierStart;
|
|
38
|
+
identContinue = identifierContinue;
|
|
39
|
+
return this;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
this.$get = [
|
|
43
|
+
"$filter",
|
|
56
44
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param
|
|
59
|
-
* @returns
|
|
45
|
+
*
|
|
46
|
+
* @param {(any) => any} $filter
|
|
47
|
+
* @returns {import('./interface').ParseService}
|
|
60
48
|
*/
|
|
61
|
-
function $
|
|
62
|
-
|
|
49
|
+
function ($filter) {
|
|
50
|
+
/** @type {import("./lexer/lexer.js").LexerOptions} */
|
|
51
|
+
const $lexerOptions = {
|
|
52
|
+
isIdentifierStart: isFunction(identStart) && identStart,
|
|
53
|
+
isIdentifierContinue: isFunction(identContinue) && identContinue,
|
|
54
|
+
};
|
|
55
|
+
return $parse;
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} exp
|
|
59
|
+
* @param interceptorFn
|
|
60
|
+
* @returns any
|
|
61
|
+
*/
|
|
62
|
+
function $parse(exp, interceptorFn) {
|
|
63
|
+
let parsedExpression, cacheKey;
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
switch (typeof exp) {
|
|
66
|
+
case "string":
|
|
67
|
+
exp = exp.trim();
|
|
68
|
+
cacheKey = exp;
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
const lexer = new Lexer($lexerOptions);
|
|
73
|
-
const parser = new Parser(lexer, $filter);
|
|
74
|
-
parsedExpression = parser.parse(exp);
|
|
70
|
+
parsedExpression = cache[cacheKey];
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
if (!parsedExpression) {
|
|
73
|
+
const lexer = new Lexer($lexerOptions);
|
|
74
|
+
const parser = new Parser(lexer, $filter);
|
|
75
|
+
parsedExpression = parser.parse(exp);
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
cache[cacheKey] = addWatchDelegate(parsedExpression);
|
|
78
|
+
}
|
|
79
|
+
return addInterceptor(parsedExpression, interceptorFn);
|
|
82
80
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}
|
|
81
|
+
case "function":
|
|
82
|
+
return addInterceptor(exp, interceptorFn);
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* @returns {import('./interface').CompiledExpression|*}
|
|
92
|
-
*/
|
|
93
|
-
function addInterceptor(parsedExpression, interceptorFn) {
|
|
94
|
-
if (!interceptorFn) return parsedExpression;
|
|
95
|
-
|
|
96
|
-
// Extract any existing interceptors out of the parsedExpression
|
|
97
|
-
// to ensure the original parsedExpression is always the $$intercepted
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
if (parsedExpression.$$interceptor) {
|
|
100
|
-
interceptorFn = chainInterceptors(
|
|
101
|
-
// @ts-ignore
|
|
102
|
-
parsedExpression.$$interceptor,
|
|
103
|
-
interceptorFn,
|
|
104
|
-
);
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
parsedExpression = parsedExpression.$$intercepted;
|
|
84
|
+
default:
|
|
85
|
+
return addInterceptor(() => {}, interceptorFn);
|
|
86
|
+
}
|
|
107
87
|
}
|
|
108
88
|
|
|
109
|
-
|
|
89
|
+
/**
|
|
90
|
+
* @param {Function} parsedExpression
|
|
91
|
+
* @param interceptorFn
|
|
92
|
+
* @returns {import('./interface').CompiledExpression|*}
|
|
93
|
+
*/
|
|
94
|
+
function addInterceptor(parsedExpression, interceptorFn) {
|
|
95
|
+
if (!interceptorFn) {
|
|
96
|
+
return parsedExpression;
|
|
97
|
+
}
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (scope?.getter) {
|
|
123
|
-
return;
|
|
99
|
+
// Extract any existing interceptors out of the parsedExpression
|
|
100
|
+
// to ensure the original parsedExpression is always the $$intercepted
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
if (parsedExpression.$$interceptor) {
|
|
103
|
+
interceptorFn = chainInterceptors(
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
parsedExpression.$$interceptor,
|
|
106
|
+
interceptorFn,
|
|
107
|
+
);
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
parsedExpression = parsedExpression.$$intercepted;
|
|
124
110
|
}
|
|
125
|
-
const res = isFunction(value) ? value() : value;
|
|
126
|
-
return interceptorFn(isProxy(res) ? res.$target : res);
|
|
127
|
-
};
|
|
128
111
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
112
|
+
let useInputs = false;
|
|
113
|
+
|
|
114
|
+
const fn = function interceptedExpression(
|
|
115
|
+
scope,
|
|
116
|
+
locals,
|
|
117
|
+
assign,
|
|
118
|
+
inputs,
|
|
119
|
+
) {
|
|
120
|
+
const value =
|
|
121
|
+
useInputs && inputs
|
|
122
|
+
? inputs[0]
|
|
123
|
+
: parsedExpression(scope, locals, assign, inputs);
|
|
124
|
+
// Do not invoke for getters
|
|
125
|
+
if (scope?.getter) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const res = isFunction(value) ? value() : value;
|
|
129
|
+
return interceptorFn(isProxy(res) ? res.$target : res);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// Maintain references to the interceptor/intercepted
|
|
133
|
+
fn.$$intercepted = parsedExpression;
|
|
134
|
+
fn.$$interceptor = interceptorFn;
|
|
135
|
+
|
|
136
|
+
// Propagate the literal/oneTime/constant attributes
|
|
147
137
|
// @ts-ignore
|
|
148
|
-
|
|
138
|
+
fn.literal = parsedExpression.literal;
|
|
149
139
|
// @ts-ignore
|
|
150
|
-
fn.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
140
|
+
fn.oneTime = parsedExpression.oneTime;
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
fn.constant = parsedExpression.constant;
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
fn.decoratedNode = parsedExpression.decoratedNode;
|
|
145
|
+
|
|
146
|
+
// Treat the interceptor like filters.
|
|
147
|
+
// If it is not $stateful then only watch its inputs.
|
|
148
|
+
// If the expression itself has no inputs then use the full expression as an input.
|
|
149
|
+
if (!interceptorFn.$stateful) {
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
useInputs = !parsedExpression.inputs;
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
fn.inputs = parsedExpression.inputs
|
|
154
|
+
? // @ts-ignore
|
|
155
|
+
parsedExpression.inputs
|
|
156
|
+
: [parsedExpression];
|
|
157
|
+
|
|
158
|
+
if (!interceptorFn.$$pure) {
|
|
159
|
+
fn.inputs = fn.inputs.map(function (e) {
|
|
160
|
+
// Remove the isPure flag of inputs when it is not absolute because they are now wrapped in a
|
|
161
|
+
// non-pure interceptor function.
|
|
162
|
+
if (e.isPure === PURITY_RELATIVE) {
|
|
163
|
+
return function depurifier(s) {
|
|
164
|
+
return e(s);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return e;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
166
170
|
}
|
|
167
|
-
}
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
return addWatchDelegate(fn);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
}
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
export function constantWatchDelegate(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFunction, csp } from "../../shared/utils.js";
|
|
2
2
|
import { createInjector } from "../di/injector.js";
|
|
3
|
-
import { Angular } from "../../
|
|
3
|
+
import { Angular } from "../../angular.js";
|
|
4
4
|
import { wait } from "../../shared/test-utils.js";
|
|
5
5
|
|
|
6
6
|
describe("parser", () => {
|
|
@@ -94,11 +94,11 @@ describe("parser", () => {
|
|
|
94
94
|
expect(scope.$eval("1<=1")).toBeTruthy();
|
|
95
95
|
expect(scope.$eval("1>2")).toEqual(1 > 2);
|
|
96
96
|
expect(scope.$eval("2>=1")).toEqual(2 >= 1);
|
|
97
|
-
expect(scope.$eval("true==2<3")).toEqual(2 < 3
|
|
98
|
-
expect(scope.$eval("true===2<3")).toEqual(2 < 3
|
|
97
|
+
expect(scope.$eval("true==2<3")).toEqual(2 < 3);
|
|
98
|
+
expect(scope.$eval("true===2<3")).toEqual(2 < 3);
|
|
99
99
|
|
|
100
100
|
expect(scope.$eval("true===3===3")).toEqual((true === 3) === 3);
|
|
101
|
-
expect(scope.$eval("3===3===true")).toEqual(
|
|
101
|
+
expect(scope.$eval("3===3===true")).toEqual(true);
|
|
102
102
|
expect(scope.$eval("3 >= 3 > 2")).toEqual(3 >= 3 > 2);
|
|
103
103
|
});
|
|
104
104
|
|
|
@@ -106,16 +106,16 @@ describe("parser", () => {
|
|
|
106
106
|
expect(scope.$eval("0&&2")).toEqual(0 && 2);
|
|
107
107
|
expect(scope.$eval("0||2")).toEqual(0 || 2);
|
|
108
108
|
expect(scope.$eval("0||1&&2")).toEqual(0 || (1 && 2));
|
|
109
|
-
expect(scope.$eval("true&&a")).toEqual(
|
|
110
|
-
expect(scope.$eval("true&&a()")).toEqual(
|
|
111
|
-
expect(scope.$eval("true&&a()()")).toEqual(
|
|
112
|
-
expect(scope.$eval("true&&a.b")).toEqual(
|
|
113
|
-
expect(scope.$eval("true&&a.b.c")).toEqual(
|
|
114
|
-
expect(scope.$eval("false||a")).toEqual(
|
|
115
|
-
expect(scope.$eval("false||a()")).toEqual(
|
|
116
|
-
expect(scope.$eval("false||a()()")).toEqual(
|
|
117
|
-
expect(scope.$eval("false||a.b")).toEqual(
|
|
118
|
-
expect(scope.$eval("false||a.b.c")).toEqual(
|
|
109
|
+
expect(scope.$eval("true&&a")).toEqual(undefined);
|
|
110
|
+
expect(scope.$eval("true&&a()")).toEqual(undefined);
|
|
111
|
+
expect(scope.$eval("true&&a()()")).toEqual(undefined);
|
|
112
|
+
expect(scope.$eval("true&&a.b")).toEqual(undefined);
|
|
113
|
+
expect(scope.$eval("true&&a.b.c")).toEqual(undefined);
|
|
114
|
+
expect(scope.$eval("false||a")).toEqual(undefined);
|
|
115
|
+
expect(scope.$eval("false||a()")).toEqual(undefined);
|
|
116
|
+
expect(scope.$eval("false||a()()")).toEqual(undefined);
|
|
117
|
+
expect(scope.$eval("false||a.b")).toEqual(undefined);
|
|
118
|
+
expect(scope.$eval("false||a.b.c")).toEqual(undefined);
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
it("should parse ternary", () => {
|
|
@@ -278,10 +278,11 @@ describe("parser", () => {
|
|
|
278
278
|
|
|
279
279
|
[2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 42, 99].forEach((pathLength) => {
|
|
280
280
|
it(`should resolve nested paths of length ${pathLength}`, () => {
|
|
281
|
+
let i;
|
|
281
282
|
// Create a nested object {x2: {x3: {x4: ... {x[n]: 42} ... }}}.
|
|
282
283
|
let obj = 42;
|
|
283
284
|
const locals = {};
|
|
284
|
-
for (
|
|
285
|
+
for (i = pathLength; i >= 2; i--) {
|
|
285
286
|
const newObj = {};
|
|
286
287
|
newObj[`x${i}`] = obj;
|
|
287
288
|
obj = newObj;
|
|
@@ -613,7 +614,7 @@ describe("parser", () => {
|
|
|
613
614
|
});
|
|
614
615
|
|
|
615
616
|
it("should evaluate negation", () => {
|
|
616
|
-
expect(scope.$eval("!false || true")).toEqual(
|
|
617
|
+
expect(scope.$eval("!false || true")).toEqual(true);
|
|
617
618
|
expect(scope.$eval("!11 == 10")).toEqual(!11 == 10);
|
|
618
619
|
expect(scope.$eval("12/6/2")).toEqual(12 / 6 / 2);
|
|
619
620
|
});
|
|
@@ -1786,37 +1787,36 @@ describe("parser", () => {
|
|
|
1786
1787
|
});
|
|
1787
1788
|
|
|
1788
1789
|
[0, false, "", NaN].forEach((falsyValue) => {
|
|
1789
|
-
"should not overwrite $prop scope properties when assigning",
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
/* ignore exception */
|
|
1817
|
-
}
|
|
1790
|
+
it("should not overwrite $prop scope properties when assigning", () => {
|
|
1791
|
+
let scope;
|
|
1792
|
+
|
|
1793
|
+
scope = { a: falsyValue, c: falsyValue };
|
|
1794
|
+
tryParseAndIgnoreException("a.b = 1");
|
|
1795
|
+
tryParseAndIgnoreException('c["d"] = 2');
|
|
1796
|
+
expect(scope).toEqual({ a: falsyValue, c: falsyValue });
|
|
1797
|
+
|
|
1798
|
+
scope = { a: { b: falsyValue, c: falsyValue } };
|
|
1799
|
+
tryParseAndIgnoreException("a.b.c = 1");
|
|
1800
|
+
tryParseAndIgnoreException('a.c["d"] = 2');
|
|
1801
|
+
expect(scope).toEqual({ a: { b: falsyValue, c: falsyValue } });
|
|
1802
|
+
|
|
1803
|
+
// Helpers
|
|
1804
|
+
//
|
|
1805
|
+
// Normally assigning property on a primitive should throw exception in strict mode
|
|
1806
|
+
// and silently fail in non-strict mode, IE seems to always have the non-strict-mode behavior,
|
|
1807
|
+
// so if we try to use 'expect(() => {$parse('a.b=1')({a:false});).toThrow()' for testing
|
|
1808
|
+
// the test will fail in case of IE because it will not throw exception, and if we just use
|
|
1809
|
+
// '$parse('a.b=1')({a:false})' the test will fail because it will throw exception in case of Chrome
|
|
1810
|
+
// so we use tryParseAndIgnoreException helper to catch the exception silently for all cases.
|
|
1811
|
+
//
|
|
1812
|
+
function tryParseAndIgnoreException(expression) {
|
|
1813
|
+
try {
|
|
1814
|
+
$parse(expression)(scope);
|
|
1815
|
+
} catch (error) {
|
|
1816
|
+
/* ignore exception */
|
|
1818
1817
|
}
|
|
1819
|
-
}
|
|
1818
|
+
}
|
|
1819
|
+
});
|
|
1820
1820
|
});
|
|
1821
1821
|
});
|
|
1822
1822
|
|
package/src/core/prop.spec.js
CHANGED
package/src/core/scope/scope.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isUndefined,
|
|
3
|
-
nextUid,
|
|
4
|
-
isObject,
|
|
5
|
-
concat,
|
|
6
|
-
isFunction,
|
|
7
2
|
assert,
|
|
8
|
-
|
|
3
|
+
concat,
|
|
4
|
+
hasOwn,
|
|
9
5
|
isDefined,
|
|
6
|
+
isFunction,
|
|
10
7
|
isNull,
|
|
8
|
+
isObject,
|
|
11
9
|
isProxy,
|
|
12
10
|
isProxySymbol,
|
|
13
|
-
|
|
11
|
+
isString,
|
|
12
|
+
isUndefined,
|
|
13
|
+
nextUid,
|
|
14
14
|
} from "../../shared/utils.js";
|
|
15
15
|
import { ASTType } from "../parse/ast-type.js";
|
|
16
16
|
|
|
@@ -97,7 +97,7 @@ export function createScope(target = {}, context) {
|
|
|
97
97
|
Array.isArray(target.$nonscope) &&
|
|
98
98
|
target.$nonscope.includes(key))
|
|
99
99
|
) {
|
|
100
|
-
|
|
100
|
+
/* empty */
|
|
101
101
|
} else {
|
|
102
102
|
target[key] = createScope(target[key], proxy.$handler);
|
|
103
103
|
}
|
|
@@ -577,6 +577,7 @@ export class Scope {
|
|
|
577
577
|
|
|
578
578
|
/**
|
|
579
579
|
* @param {Listener[]} listeners
|
|
580
|
+
* @param {Function} filter
|
|
580
581
|
*/
|
|
581
582
|
#scheduleListener(listeners, filter = (val) => val) {
|
|
582
583
|
Promise.resolve().then(() => {
|
|
@@ -1231,8 +1232,7 @@ export class Scope {
|
|
|
1231
1232
|
function calculateWatcherCount(model) {
|
|
1232
1233
|
const childIds = collectChildIds(model).add(model.$id);
|
|
1233
1234
|
|
|
1234
|
-
|
|
1235
|
-
const count = Array.from(model.watchers.values()).reduce(
|
|
1235
|
+
return Array.from(model.watchers.values()).reduce(
|
|
1236
1236
|
(count, watcherArray) =>
|
|
1237
1237
|
count +
|
|
1238
1238
|
watcherArray.reduce(
|
|
@@ -1242,7 +1242,6 @@ function calculateWatcherCount(model) {
|
|
|
1242
1242
|
),
|
|
1243
1243
|
0,
|
|
1244
1244
|
);
|
|
1245
|
-
return count;
|
|
1246
1245
|
}
|
|
1247
1246
|
|
|
1248
1247
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { wait } from "../../shared/test-utils.js";
|
|
2
2
|
import { $postUpdateQueue, createScope } from "./scope.js";
|
|
3
|
-
import { Angular } from "../../
|
|
3
|
+
import { Angular } from "../../angular.js";
|
|
4
4
|
import { createInjector } from "../di/injector.js";
|
|
5
|
-
import { isDefined,
|
|
5
|
+
import { isDefined, isProxy, sliceArgs } from "../../shared/utils.js";
|
|
6
6
|
|
|
7
7
|
describe("Scope", () => {
|
|
8
8
|
let scope;
|
|
@@ -1729,8 +1729,7 @@ describe("Scope", () => {
|
|
|
1729
1729
|
describe("watching other proxies", () => {
|
|
1730
1730
|
it("should register a foreign proxies ", async () => {
|
|
1731
1731
|
let scope1 = createScope();
|
|
1732
|
-
|
|
1733
|
-
scope1.service = scope2;
|
|
1732
|
+
scope1.service = createScope({ b: 2 });
|
|
1734
1733
|
expect(scope1.$handler.foreignProxies.size).toEqual(1);
|
|
1735
1734
|
});
|
|
1736
1735
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInjector } from "../../core/di/injector.js";
|
|
2
|
-
import { Angular } from "../../
|
|
2
|
+
import { Angular } from "../../angular.js";
|
|
3
3
|
import { dealoc, getController } from "../../shared/dom.js";
|
|
4
4
|
import { browserTrigger, wait } from "../../shared/test-utils.js";
|
|
5
5
|
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/directive/aria/aria.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/directive/attrs/attrs.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/directive/attrs/boolean.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(3000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Angular } from "../../
|
|
1
|
+
import { Angular } from "../../angular.js";
|
|
2
2
|
import { createInjector } from "../../core/di/injector.js";
|
|
3
3
|
import { createElementFromHTML, dealoc } from "../../shared/dom.js";
|
|
4
4
|
import { wait } from "../../shared/test-utils.js";
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/directive/attrs/element-style.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(3000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/directive/attrs/src.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|