@angular-wave/angular.ts 0.7.3 → 0.7.4
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/.prettierignore +2 -1
- package/@types/core/exception-handler.d.ts +2 -2
- package/@types/core/task-tracker-factory.d.ts +2 -2
- package/@types/directive/channel/channel.d.ts +2 -18
- package/@types/directive/http/http.d.ts +3 -0
- package/@types/directive/script/script.d.ts +2 -2
- package/@types/directive/setter/setter.d.ts +2 -2
- package/@types/injection-tokens.d.ts +3 -0
- package/@types/interface.d.ts +11 -0
- package/@types/loader.d.ts +3 -4
- package/@types/router/params/param-factory.d.ts +10 -2
- package/@types/router/params/param.d.ts +22 -3
- package/@types/router/template-factory.d.ts +2 -2
- package/@types/router/url/url-service.d.ts +2 -2
- package/@types/services/http/http.d.ts +2 -2
- package/@types/services/http/interface.d.ts +219 -0
- package/@types/services/http-backend/http-backend.d.ts +26 -19
- package/@types/services/log/interface.d.ts +33 -0
- package/@types/services/log/log.d.ts +25 -0
- package/@types/{core → services}/pubsub/pubsub.d.ts +6 -6
- package/@types/services/template-cache/interface.d.ts +4 -0
- package/@types/services/template-cache/template-cache.d.ts +11 -0
- package/@types/services/template-request.d.ts +1 -1
- package/@types/shared/cache.d.ts +9 -0
- package/@types/shared/dom.d.ts +2 -2
- package/Makefile +1 -1
- package/dist/angular-ts.esm.js +147 -141
- package/dist/angular-ts.umd.js +147 -141
- package/dist/angular-ts.umd.min.js +1 -1
- package/docs/assets/scss/_variables_project.scss +1 -1
- package/docs/assets/scss/_variables_project_after_bs.scss +5 -5
- package/docs/assets/scss/index.scss +2 -3
- package/docs/content/_index.md +1 -1
- package/docs/content/docs/_index.md +58 -25
- package/docs/content/docs/directive/_index.md +4 -0
- package/docs/content/docs/directive/app.md +11 -0
- package/docs/content/docs/directive/aria.md +0 -0
- package/docs/content/docs/directive/channel.md +39 -0
- package/docs/content/docs/directive/class-even.md +47 -0
- package/docs/content/docs/directive/class-odd.md +48 -0
- package/docs/content/docs/directive/class.md +64 -0
- package/docs/content/docs/directive/cloak.md +78 -0
- package/docs/content/docs/directive/include.md +7 -0
- package/docs/content/docs/filter/_index.md +4 -0
- package/docs/content/docs/provider/_index.md +4 -0
- package/docs/content/docs/provider/eventBusProvider.md +35 -0
- package/docs/content/docs/provider/logProvider.md +59 -0
- package/docs/content/docs/provider/templateCacheProvider.md +35 -0
- package/docs/content/docs/service/_index.md +4 -0
- package/docs/content/docs/service/eventBus.md +56 -0
- package/docs/content/docs/service/log.md +113 -0
- package/docs/content/docs/service/templateCache.md +64 -0
- package/docs/hugo.yaml +3 -3
- package/docs/layouts/partials/hooks/head-end.html +3 -0
- package/docs/layouts/shortcodes/showhtml.html +2 -0
- package/docs/layouts/shortcodes/showjs.html +2 -0
- package/docs/layouts/shortcodes/showraw.html +1 -0
- package/docs/static/examples/counter/counter-test.html +17 -0
- package/docs/static/examples/counter/counter.html +5 -0
- package/docs/static/examples/counter/counter.test.js +28 -0
- package/docs/static/examples/eventbus/eventbus-test.html +19 -0
- package/docs/static/examples/eventbus/eventbus.html +13 -0
- package/docs/static/examples/eventbus/eventbus.js +15 -0
- package/docs/static/examples/eventbus/eventbus.test.js +19 -0
- package/docs/static/examples/ng-channel/ng-channel-test.html +17 -0
- package/docs/static/examples/ng-channel/ng-channel.html +24 -0
- package/docs/static/examples/ng-channel/ng-channel.test.js +31 -0
- package/docs/static/examples/ng-class/ng-class.html +71 -0
- package/docs/static/examples/ng-class/ng-class.js +0 -0
- package/docs/static/examples/ng-class-even/ng-class-even.html +8 -0
- package/docs/static/examples/ng-class-odd/ng-class-odd.html +8 -0
- package/docs/static/typedoc/assets/hierarchy.js +1 -1
- package/docs/static/typedoc/assets/navigation.js +1 -1
- package/docs/static/typedoc/assets/search.js +1 -1
- package/docs/static/typedoc/classes/LogProvider.html +6 -0
- package/docs/static/typedoc/classes/PubSub.html +71 -0
- package/docs/static/typedoc/classes/PubSubProvider.html +3 -0
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +5 -0
- package/docs/static/typedoc/hierarchy.html +1 -1
- package/docs/static/typedoc/index.html +1 -1
- package/docs/static/typedoc/interfaces/ChangesObject.html +1 -1
- package/docs/static/typedoc/interfaces/ComponentOptions.html +1 -1
- package/docs/static/typedoc/interfaces/Controller.html +1 -1
- package/docs/static/typedoc/interfaces/Directive.html +1 -1
- package/docs/static/typedoc/interfaces/DirectivePrePost.html +1 -1
- package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +1 -0
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +31 -0
- package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +6 -0
- package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +1 -0
- package/docs/static/typedoc/interfaces/HttpResponse.html +8 -0
- package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +1 -0
- package/docs/static/typedoc/interfaces/HttpService.html +38 -0
- package/docs/static/typedoc/interfaces/LogService.html +12 -0
- package/docs/static/typedoc/interfaces/NgModelController.html +1 -1
- package/docs/static/typedoc/interfaces/NgModelOptions.html +1 -1
- package/docs/static/typedoc/interfaces/Provider.html +1 -1
- package/docs/static/typedoc/interfaces/RequestConfig.html +48 -0
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +38 -0
- package/docs/static/typedoc/interfaces/ServiceProvider.html +1 -1
- package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +1 -1
- package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
- package/docs/static/typedoc/types/CloneAttachFunction.html +1 -1
- package/docs/static/typedoc/types/ControllerConstructor.html +1 -1
- package/docs/static/typedoc/types/DirectiveCompileFn.html +1 -1
- package/docs/static/typedoc/types/DirectiveController.html +1 -1
- package/docs/static/typedoc/types/DirectiveFactory.html +1 -1
- package/docs/static/typedoc/types/DirectiveLinkFn.html +1 -1
- package/docs/static/typedoc/types/ExpandoStore.html +2 -0
- package/docs/static/typedoc/types/Expression.html +1 -1
- package/docs/static/typedoc/types/FilterFactory.html +1 -1
- package/docs/static/typedoc/types/FilterFn.html +1 -1
- package/docs/static/typedoc/types/HttpPromise.html +1 -0
- package/docs/static/typedoc/types/Injectable.html +1 -1
- package/docs/static/typedoc/types/InjectableFactory.html +1 -1
- package/docs/static/typedoc/types/LogCall.html +2 -0
- package/docs/static/typedoc/types/LogServiceFactory.html +2 -0
- package/docs/static/typedoc/types/OnChangesObject.html +1 -1
- package/docs/static/typedoc/types/SwapInsertPosition.html +1 -1
- package/docs/static/typedoc/types/TController.html +1 -1
- package/docs/static/typedoc/types/TemplateCache.html +2 -0
- package/docs/static/typedoc/variables/EventBus.html +1 -0
- package/index.html +4 -2
- package/package.json +3 -3
- package/src/animations/animate-css.js +5 -1
- package/src/binding.spec.js +3 -1
- package/src/core/compile/compile.spec.js +12 -5
- package/src/core/core.html +0 -1
- package/src/core/exception-handler.js +1 -1
- package/src/core/prop.spec.js +1 -0
- package/src/core/task-tracker-factory.js +2 -2
- package/src/directive/bind/bind.spec.js +1 -4
- package/src/directive/channel/channel.js +8 -24
- package/src/directive/channel/channel.spec.js +4 -2
- package/src/directive/class/class.js +16 -0
- package/src/directive/class/class.spec.js +2 -0
- package/src/directive/events/event.spec.js +1 -0
- package/src/directive/form/form.spec.js +2 -0
- package/src/directive/http/http.js +4 -4
- package/src/directive/if/if.spec.js +2 -0
- package/src/directive/include/include.spec.js +1 -0
- package/src/directive/input/input.spec.js +1 -0
- package/src/directive/model/model.spec.js +3 -0
- package/src/directive/model-options/model-options.spec.js +2 -0
- package/src/directive/observe/observe.spec.js +2 -1
- package/src/{core/pubsub/pubsub.html → directive/on/on.html} +1 -1
- package/src/{core → directive/on}/on.spec.js +5 -3
- package/src/directive/on/on.test.js +11 -0
- package/src/directive/options/options.spec.js +1 -0
- package/src/directive/script/script.js +1 -1
- package/src/directive/select/select.spec.js +1 -0
- package/src/directive/setter/setter.js +1 -1
- package/src/directive/setter/setter.spec.js +2 -0
- package/src/directive/switch/switch.spec.js +1 -0
- package/src/injection-tokens.js +3 -0
- package/src/interface.ts +10 -0
- package/src/loader.js +3 -6
- package/src/public.js +3 -3
- package/src/router/directives/state-directives.spec.js +3 -1
- package/src/router/params/param-factory.js +6 -0
- package/src/router/params/param.js +22 -7
- package/src/router/router.html +0 -1
- package/src/router/router.test.js +2 -1
- package/src/router/services.spec.js +2 -0
- package/src/router/state/state-builder.js +3 -0
- package/src/router/state/state-builder.spec.js +2 -0
- package/src/router/state/state-service.js +1 -1
- package/src/router/state-filter.spec.js +2 -0
- package/src/router/template-factory.html +19 -0
- package/src/router/template-factory.js +3 -3
- package/src/router/template-factory.spec.js +1 -0
- package/src/router/template-factory.test.js +12 -0
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/url/url-service.js +1 -1
- package/src/router/view-scroll.spec.js +3 -1
- package/src/services/http/http.js +4 -4
- package/src/services/http/http.test.js +1 -1
- package/src/services/http/interface.ts +243 -0
- package/src/services/http-backend/http-backend.js +21 -11
- package/src/services/log/interface.ts +39 -0
- package/src/services/log/log.html +19 -0
- package/src/services/log/log.js +74 -0
- package/src/services/log/log.spec.js +64 -0
- package/src/services/log/log.test.js +11 -0
- package/src/services/pubsub/pubsub.html +19 -0
- package/src/{core → services}/pubsub/pubsub.js +6 -5
- package/src/{core → services}/pubsub/pubsub.spec.js +3 -3
- package/src/{core → services}/pubsub/pubsub.test.js +1 -1
- package/src/services/template-cache/interface.ts +4 -0
- package/src/services/template-cache/template-cache.html +22 -0
- package/src/services/template-cache/template-cache.js +13 -0
- package/src/services/template-cache/template-cache.spec.js +62 -0
- package/src/services/template-cache/template-cache.test.js +11 -0
- package/src/services/template-request.js +2 -2
- package/src/shared/cache.js +9 -0
- package/src/shared/dom.js +13 -7
- package/utils/express.js +7 -9
- package/@types/core/cache/cache-factory.d.ts +0 -22
- package/@types/core/cache/cache.d.ts +0 -28
- package/@types/services/log.d.ts +0 -53
- package/src/core/cache/cache-factory.js +0 -19
- package/src/core/cache/cache.js +0 -27
- package/src/directive/class/class.md +0 -90
- package/src/directive/cloak/cloak.md +0 -24
- package/src/examples/counter.html +0 -20
- package/src/services/log.js +0 -95
- package/src/services/log.md +0 -39
|
@@ -3,38 +3,22 @@ import { $injectTokens } from "../../injection-tokens.js";
|
|
|
3
3
|
|
|
4
4
|
ngChannelDirective.$inject = [$injectTokens.$eventBus];
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* If data is sent via `$eventBus` on the specified `ngChannel`, the directive attempts to update the element's content accordingly,
|
|
8
|
-
* either by directly setting the inner HTML or merging the scope's data if the element contains a template.
|
|
9
|
-
*
|
|
10
|
-
* If the element has a template and incoming data is an object, the directive will merge all key/value pairs onto the scope,
|
|
11
|
-
* allowing Angular expressions (`{{ yourModel }}`) to be evaluated and rendered.
|
|
12
|
-
*
|
|
13
|
-
* When the scope is destroyed, the directive automatically unsubscribes from the channel.
|
|
14
|
-
* Example:
|
|
15
|
-
*
|
|
16
|
-
* HTML:
|
|
17
|
-
* <div ng-channel="userChannel">Hello {{ user.firstName }} {{ user.lastName }}</div>
|
|
18
|
-
*
|
|
19
|
-
* JavaScript:
|
|
20
|
-
* angular.$eventBus.publish('userChannel', { user: { firstName: 'John', lastName: 'Smith' } });
|
|
21
|
-
*
|
|
22
|
-
* @param {import("../../core/pubsub/pubsub.js").PubSub} $eventBus
|
|
6
|
+
* @param {import("../../services/pubsub/pubsub.js").PubSub} $eventBus
|
|
23
7
|
* @returns {import("../../interface.ts").Directive}
|
|
24
8
|
*/
|
|
25
9
|
export function ngChannelDirective($eventBus) {
|
|
26
10
|
return {
|
|
27
11
|
link: (scope, element, attrs) => {
|
|
28
|
-
const hasTemplate = element.childNodes.length > 0;
|
|
29
12
|
const channel = attrs["ngChannel"];
|
|
13
|
+
const hasTemplateContent = element.childNodes.length > 0;
|
|
30
14
|
|
|
31
|
-
const key = $eventBus.subscribe(channel, (
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (isObject(val)) {
|
|
36
|
-
scope.$merge(val);
|
|
15
|
+
const key = $eventBus.subscribe(channel, (value) => {
|
|
16
|
+
if (hasTemplateContent) {
|
|
17
|
+
if (isObject(value)) {
|
|
18
|
+
scope.$merge(value);
|
|
37
19
|
}
|
|
20
|
+
} else {
|
|
21
|
+
element.innerHTML = value;
|
|
38
22
|
}
|
|
39
23
|
});
|
|
40
24
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Angular } from "../../loader.js";
|
|
2
|
-
import { EventBus } from "../../
|
|
2
|
+
import { EventBus } from "../../services/pubsub/pubsub.js";
|
|
3
|
+
import { dealoc } from "../../shared/dom.js";
|
|
3
4
|
import { wait } from "../../shared/test-utils.js";
|
|
4
5
|
|
|
5
6
|
describe("channel", () => {
|
|
6
7
|
let $compile, $scope, element, unsubscribeSpy;
|
|
7
8
|
|
|
8
9
|
beforeEach(() => {
|
|
9
|
-
|
|
10
|
+
dealoc(document.getElementById("app"));
|
|
11
|
+
let angular = new Angular();
|
|
10
12
|
angular.module("myModule", ["ng"]);
|
|
11
13
|
angular
|
|
12
14
|
.bootstrap(document.getElementById("app"), ["myModule"])
|
|
@@ -2,6 +2,8 @@ import { getCacheData, setCacheData } from "../../shared/dom.js";
|
|
|
2
2
|
import { hasAnimate, isObject, isString } from "../../shared/utils.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* @param {string} name
|
|
6
|
+
* @param {boolean|number} selector
|
|
5
7
|
* @returns {() => import("../../interface.ts").Directive}
|
|
6
8
|
*/
|
|
7
9
|
function classDirective(name, selector) {
|
|
@@ -17,6 +19,7 @@ function classDirective(name, selector) {
|
|
|
17
19
|
link(scope, element, attr) {
|
|
18
20
|
let classCounts = getCacheData(element, "$classCounts");
|
|
19
21
|
let oldModulo = true;
|
|
22
|
+
/** @type {string|undefined} */
|
|
20
23
|
let oldClassString;
|
|
21
24
|
|
|
22
25
|
if (!classCounts) {
|
|
@@ -35,6 +38,9 @@ function classDirective(name, selector) {
|
|
|
35
38
|
ngClassWatchAction(toClassString(val));
|
|
36
39
|
});
|
|
37
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} classString
|
|
43
|
+
*/
|
|
38
44
|
function addClasses(classString) {
|
|
39
45
|
classString = digestClassCounts(split(classString), 1);
|
|
40
46
|
if (hasAnimate(element)) {
|
|
@@ -48,6 +54,9 @@ function classDirective(name, selector) {
|
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} classString
|
|
59
|
+
*/
|
|
51
60
|
function removeClasses(classString) {
|
|
52
61
|
classString = digestClassCounts(split(classString), -1);
|
|
53
62
|
if (hasAnimate(element)) {
|
|
@@ -61,6 +70,10 @@ function classDirective(name, selector) {
|
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} oldClassString
|
|
75
|
+
* @param {string} newClassString
|
|
76
|
+
*/
|
|
64
77
|
function updateClasses(oldClassString, newClassString) {
|
|
65
78
|
const oldClassArray = split(oldClassString);
|
|
66
79
|
const newClassArray = split(newClassString);
|
|
@@ -111,6 +124,9 @@ function classDirective(name, selector) {
|
|
|
111
124
|
oldModulo = newModulo;
|
|
112
125
|
}
|
|
113
126
|
|
|
127
|
+
/**
|
|
128
|
+
* @param {string} newClassString
|
|
129
|
+
*/
|
|
114
130
|
function ngClassWatchAction(newClassString) {
|
|
115
131
|
if (oldModulo === selector) {
|
|
116
132
|
updateClasses(oldClassString, newClassString);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Angular } from "../../loader.js";
|
|
2
|
+
import { dealoc } from "../../shared/dom.js";
|
|
2
3
|
import { wait } from "../../shared/test-utils.js";
|
|
3
4
|
|
|
4
5
|
describe("ngClass", () => {
|
|
@@ -8,6 +9,7 @@ describe("ngClass", () => {
|
|
|
8
9
|
let injector;
|
|
9
10
|
|
|
10
11
|
beforeEach(() => {
|
|
12
|
+
dealoc(document.getElementById("app"));
|
|
11
13
|
window.angular = new Angular();
|
|
12
14
|
window.angular.module("test", []);
|
|
13
15
|
injector = window.angular.bootstrap(document.getElementById("app"), [
|
|
@@ -17,6 +17,7 @@ describe("form", () => {
|
|
|
17
17
|
let injector;
|
|
18
18
|
|
|
19
19
|
beforeEach(() => {
|
|
20
|
+
dealoc(document.getElementById("app"));
|
|
20
21
|
window.angular = new Angular();
|
|
21
22
|
window.angular
|
|
22
23
|
.module("myModule", ["ng"])
|
|
@@ -1403,6 +1404,7 @@ describe("form", () => {
|
|
|
1403
1404
|
let dummy = document.getElementById("app");
|
|
1404
1405
|
doc = '<form name="myForm"></form>';
|
|
1405
1406
|
dummy.append(doc);
|
|
1407
|
+
dealoc(document.getElementById("app"));
|
|
1406
1408
|
let angular = new Angular();
|
|
1407
1409
|
window.angular = new Angular();
|
|
1408
1410
|
myModule = window.angular.module("myModule", []);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isObject } from "../../shared/utils.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @param {"get" | "delete" | "post" | "put"} method
|
|
3
5
|
* @returns {import('../../interface.ts').DirectiveFactory}
|
|
@@ -18,8 +20,6 @@ export const ngPutDirective = defineDirective("put");
|
|
|
18
20
|
* @typedef {"click" | "change" | "submit"} EventType
|
|
19
21
|
*/
|
|
20
22
|
|
|
21
|
-
import { isObject } from "../../shared/utils";
|
|
22
|
-
|
|
23
23
|
/**
|
|
24
24
|
* Selects DOM event to listen for based on the element type.
|
|
25
25
|
*
|
|
@@ -128,9 +128,9 @@ export function handleSwapResponse(html, swap, target, scope, $compile) {
|
|
|
128
128
|
*/
|
|
129
129
|
export function createHttpDirective(method, attrName) {
|
|
130
130
|
/**
|
|
131
|
-
* @param {
|
|
131
|
+
* @param {import("interface.ts").HttpService} $http
|
|
132
132
|
* @param {import("../../core/compile/compile.js").CompileFn} $compile
|
|
133
|
-
* @param {import("../../services/log.
|
|
133
|
+
* @param {import("../../services/log/interface.ts").LogService} $log
|
|
134
134
|
* @returns {import('../../interface.ts').Directive}
|
|
135
135
|
*/
|
|
136
136
|
return function ($http, $compile, $log) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createElementFromHTML,
|
|
3
|
+
dealoc,
|
|
3
4
|
getCacheData,
|
|
4
5
|
setCacheData,
|
|
5
6
|
} from "../../shared/dom.js";
|
|
@@ -17,6 +18,7 @@ describe("ngIf", () => {
|
|
|
17
18
|
let angular;
|
|
18
19
|
|
|
19
20
|
beforeEach(function () {
|
|
21
|
+
dealoc(document.getElementById("app"));
|
|
20
22
|
angular = window.angular = new Angular();
|
|
21
23
|
window.angular.module("test", []);
|
|
22
24
|
injector = window.angular.bootstrap(document.getElementById("app"), [
|
|
@@ -17,6 +17,7 @@ describe("ngModel", () => {
|
|
|
17
17
|
|
|
18
18
|
beforeEach(() => {
|
|
19
19
|
errors = [];
|
|
20
|
+
dealoc(document.getElementById("app"));
|
|
20
21
|
window.angular = new Angular();
|
|
21
22
|
window.angular
|
|
22
23
|
.module("myModule", ["ng"])
|
|
@@ -1554,6 +1555,7 @@ describe("ngModel", () => {
|
|
|
1554
1555
|
let module;
|
|
1555
1556
|
|
|
1556
1557
|
beforeEach(() => {
|
|
1558
|
+
dealoc(document.getElementById("app"));
|
|
1557
1559
|
window.angular = new Angular();
|
|
1558
1560
|
module = window.angular
|
|
1559
1561
|
.module("myModule", [])
|
|
@@ -1900,6 +1902,7 @@ describe("data-change", () => {
|
|
|
1900
1902
|
let el = document.getElementById("app");
|
|
1901
1903
|
|
|
1902
1904
|
beforeEach(() => {
|
|
1905
|
+
dealoc(document.getElementById("app"));
|
|
1903
1906
|
window.angular = new Angular();
|
|
1904
1907
|
});
|
|
1905
1908
|
|
|
@@ -33,6 +33,7 @@ describe("ngModelOptions", () => {
|
|
|
33
33
|
let injector;
|
|
34
34
|
|
|
35
35
|
beforeEach(() => {
|
|
36
|
+
dealoc(document.getElementById("app"));
|
|
36
37
|
window.angular = new Angular();
|
|
37
38
|
window.angular
|
|
38
39
|
.module("myModule", ["ng"])
|
|
@@ -1001,6 +1002,7 @@ describe("ngModelOptions", () => {
|
|
|
1001
1002
|
let inputElm, module, $rootScope, angular;
|
|
1002
1003
|
|
|
1003
1004
|
beforeEach(() => {
|
|
1005
|
+
dealoc(document.getElementById("app"));
|
|
1004
1006
|
window.angular = angular = new Angular();
|
|
1005
1007
|
module = angular.module("myModule", []).directive("foo", () => ({
|
|
1006
1008
|
replace: true,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Angular } from "../../loader.js";
|
|
2
|
-
import { createElementFromHTML } from "../../shared/dom.js";
|
|
2
|
+
import { createElementFromHTML, dealoc } from "../../shared/dom.js";
|
|
3
3
|
import { wait } from "../../shared/test-utils.js";
|
|
4
4
|
|
|
5
5
|
describe("observe", () => {
|
|
6
6
|
let $compile, $scope, $rootScope, element, observerSpy;
|
|
7
7
|
|
|
8
8
|
beforeEach(() => {
|
|
9
|
+
dealoc(document.getElementById("app"));
|
|
9
10
|
window.angular = new Angular();
|
|
10
11
|
angular.module("myModule", ["ng"]);
|
|
11
12
|
angular
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<script src="/jasmine/jasmine-html.js"></script>
|
|
12
12
|
<script src="/jasmine/boot0.js"></script>
|
|
13
13
|
<script src="/jasmine/boot1.js"></script>
|
|
14
|
-
<script type="module" src="/src/
|
|
14
|
+
<script type="module" src="/src/directive/on/on.spec.js"></script>
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="app"></div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Angular } from "
|
|
2
|
-
import { browserTrigger, wait } from "
|
|
3
|
-
import { createInjector } from "
|
|
1
|
+
import { Angular } from "../../loader.js";
|
|
2
|
+
import { browserTrigger, wait } from "../../shared/test-utils.js";
|
|
3
|
+
import { createInjector } from "../../core/di/injector.js";
|
|
4
4
|
|
|
5
5
|
describe("ngOn* event binding", () => {
|
|
6
6
|
let $rootScope, module, injector, $compile;
|
|
@@ -19,6 +19,8 @@ describe("ngOn* event binding", () => {
|
|
|
19
19
|
const element = $compile('<span ng-on-foo="name = name + 3"></span>')(
|
|
20
20
|
$rootScope,
|
|
21
21
|
);
|
|
22
|
+
expect($rootScope.name).toBe("Misko");
|
|
23
|
+
|
|
22
24
|
browserTrigger(element, "foo");
|
|
23
25
|
expect($rootScope.name).toBe("Misko3");
|
|
24
26
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const TEST_URL = "src/directive/on/on.html";
|
|
4
|
+
|
|
5
|
+
test("unit tests contain no errors", async ({ page }) => {
|
|
6
|
+
await page.goto(TEST_URL);
|
|
7
|
+
await page.content();
|
|
8
|
+
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
|
+
/0 failures/,
|
|
10
|
+
);
|
|
11
|
+
});
|
|
@@ -160,6 +160,7 @@ describe("ngOptions", () => {
|
|
|
160
160
|
errors = [];
|
|
161
161
|
element = document.getElementById("app");
|
|
162
162
|
element.innerHTML = "test";
|
|
163
|
+
dealoc(document.getElementById("app"));
|
|
163
164
|
window.angular = new Angular();
|
|
164
165
|
window.angular
|
|
165
166
|
.module("myModule", ["ng"])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
scriptDirective.$inject = ["$templateCache"];
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {import('../../
|
|
4
|
+
* @param {import('../../services/template-cache/interface.ts').TemplateCache} $templateCache
|
|
5
5
|
* @returns {import('../../interface.ts').Directive}
|
|
6
6
|
*/
|
|
7
7
|
export function scriptDirective($templateCache) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
ngSetterDirective.$inject = ["$parse", "$log"];
|
|
2
2
|
/**
|
|
3
3
|
* @param {import('../../core/parse/interface.ts').ParseService} $parse
|
|
4
|
-
* @param {import('../../services/log.
|
|
4
|
+
* @param {import('../../services/log/interface.ts').LogService} $log
|
|
5
5
|
* @returns {import('../../interface.ts').Directive}
|
|
6
6
|
*/
|
|
7
7
|
export function ngSetterDirective($parse, $log) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Angular } from "../../loader.js";
|
|
2
|
+
import { dealoc } from "../../shared/dom.js";
|
|
2
3
|
import { wait } from "../../shared/test-utils.js";
|
|
3
4
|
|
|
4
5
|
describe("setter", () => {
|
|
5
6
|
let $compile, $rootScope, $parse, observerSpy, $log;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
9
|
+
dealoc(document.getElementById("app"));
|
|
8
10
|
window.angular = new Angular();
|
|
9
11
|
angular.module("myModule", []);
|
|
10
12
|
angular
|
package/src/injection-tokens.js
CHANGED
package/src/interface.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Attributes } from "./core/compile/attributes.js";
|
|
2
2
|
import { Scope } from "./core/scope/scope.js";
|
|
3
|
+
export * from "./services/http/interface.ts";
|
|
4
|
+
export * from "./services/log/interface.ts";
|
|
5
|
+
export * from "./services/log/log.js";
|
|
6
|
+
export * from "./services/pubsub/pubsub.js";
|
|
7
|
+
export * from "./services/template-cache/interface.ts";
|
|
8
|
+
export * from "./services/template-cache/template-cache.js";
|
|
3
9
|
|
|
4
10
|
/**
|
|
5
11
|
* A JavaScript expression represented as a string, typically used in interpolation bindings.
|
|
@@ -12,6 +18,10 @@ import { Scope } from "./core/scope/scope.js";
|
|
|
12
18
|
*/
|
|
13
19
|
export type Expression = string;
|
|
14
20
|
|
|
21
|
+
export type ExpandoStore = {
|
|
22
|
+
data: { [key: string]: any };
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
/**
|
|
16
26
|
* A dependency-annotated factory array used by AngularTS DI system.
|
|
17
27
|
*
|
package/src/loader.js
CHANGED
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
getScope,
|
|
13
13
|
setCacheData,
|
|
14
14
|
} from "./shared/dom.js";
|
|
15
|
+
import { Cache } from "./shared/cache.js";
|
|
15
16
|
import { annotate, createInjector } from "./core/di/injector.js";
|
|
16
17
|
import { NgModule } from "./core/di/ng-module.js";
|
|
17
|
-
import { Cache } from "./core/cache/cache.js";
|
|
18
18
|
import { registerNgModule } from "./public.js";
|
|
19
19
|
import { unnestR } from "./shared/common.js";
|
|
20
|
-
import { EventBus } from "./
|
|
20
|
+
import { EventBus } from "./services/pubsub/pubsub.js";
|
|
21
21
|
import { $injectTokens } from "./injection-tokens.js";
|
|
22
22
|
|
|
23
23
|
const ngMinErr = minErr("ng");
|
|
@@ -35,12 +35,9 @@ const modules = {};
|
|
|
35
35
|
|
|
36
36
|
export class Angular {
|
|
37
37
|
constructor() {
|
|
38
|
-
Cache.clear(); // a ensure new instance of angular gets a clean cache
|
|
39
|
-
|
|
40
|
-
/** @type {Map<number, import("./core/cache/cache.js").ExpandoStore>} */
|
|
41
38
|
this.$cache = Cache;
|
|
42
39
|
|
|
43
|
-
/** @type {import('./
|
|
40
|
+
/** @type {import('./services/pubsub/pubsub.js').PubSub} */
|
|
44
41
|
this.$eventBus = EventBus;
|
|
45
42
|
|
|
46
43
|
/**
|
package/src/public.js
CHANGED
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
AnimateAsyncRunFactoryProvider,
|
|
58
58
|
AnimateRunnerFactoryProvider,
|
|
59
59
|
} from "./animations/animate-runner.js";
|
|
60
|
-
import { TemplateCacheProvider } from "./
|
|
60
|
+
import { TemplateCacheProvider } from "./services/template-cache/template-cache.js";
|
|
61
61
|
import { ControllerProvider } from "./core/controller/controller.js";
|
|
62
62
|
import { ExceptionHandlerProvider } from "./core/exception-handler.js";
|
|
63
63
|
import { FilterProvider } from "./core/filter/filter.js";
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
} from "./services/http/http.js";
|
|
69
69
|
import { HttpBackendProvider } from "./services/http-backend/http-backend.js";
|
|
70
70
|
import { LocationProvider } from "./core/location/location.js";
|
|
71
|
-
import { LogProvider } from "./services/log.js";
|
|
71
|
+
import { LogProvider } from "./services/log/log.js";
|
|
72
72
|
import { ParseProvider } from "./core/parse/parse.js";
|
|
73
73
|
import { RootScopeProvider } from "./core/scope/scope.js";
|
|
74
74
|
import { SceProvider, SceDelegateProvider } from "./core/sce/sce.js";
|
|
@@ -127,7 +127,7 @@ import {
|
|
|
127
127
|
} from "./router/directives/view-directive.js";
|
|
128
128
|
import { ngChannelDirective } from "./directive/channel/channel.js";
|
|
129
129
|
import { ngSetterDirective } from "./directive/setter/setter.js";
|
|
130
|
-
import { PubSubProvider } from "./
|
|
130
|
+
import { PubSubProvider } from "./services/pubsub/pubsub.js";
|
|
131
131
|
import {
|
|
132
132
|
ngDeleteDirective,
|
|
133
133
|
ngGetDirective,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Angular } from "../../loader.js";
|
|
2
|
-
import { createElementFromHTML } from "../../shared/dom.js";
|
|
2
|
+
import { createElementFromHTML, dealoc } from "../../shared/dom.js";
|
|
3
3
|
import { browserTrigger, wait } from "../../shared/test-utils.js";
|
|
4
4
|
|
|
5
5
|
describe("ngStateRef", () => {
|
|
@@ -18,6 +18,7 @@ describe("ngStateRef", () => {
|
|
|
18
18
|
$urlService;
|
|
19
19
|
|
|
20
20
|
beforeEach(() => {
|
|
21
|
+
dealoc(document.getElementById("app"));
|
|
21
22
|
app.innerHTML = "";
|
|
22
23
|
window.location.hash = "";
|
|
23
24
|
window.angular = new Angular();
|
|
@@ -663,6 +664,7 @@ describe("ngSrefActive", () => {
|
|
|
663
664
|
_stateProvider;
|
|
664
665
|
|
|
665
666
|
beforeEach(() => {
|
|
667
|
+
dealoc(document.getElementById("app"));
|
|
666
668
|
window.location.hash = "";
|
|
667
669
|
window.angular = new Angular();
|
|
668
670
|
let module = window.angular.module("defaultModule", []);
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { DefType, Param } from "./param.js";
|
|
2
2
|
|
|
3
3
|
export class ParamFactory {
|
|
4
|
+
/**
|
|
5
|
+
* @param {import("../url/url-config.js").UrlConfigProvider} urlServiceConfig
|
|
6
|
+
*/
|
|
4
7
|
constructor(urlServiceConfig) {
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("../url/url-config.js").UrlConfigProvider}
|
|
10
|
+
*/
|
|
5
11
|
this.urlServiceConfig = urlServiceConfig;
|
|
6
12
|
}
|
|
7
13
|
|
|
@@ -8,13 +8,15 @@ const isShorthand = (cfg) =>
|
|
|
8
8
|
Object.prototype.hasOwnProperty.bind(cfg || {}),
|
|
9
9
|
).length === 0;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
* @enum {number}
|
|
14
|
+
*/
|
|
15
|
+
export const DefType = {
|
|
16
|
+
PATH: 0,
|
|
17
|
+
SEARCH: 1,
|
|
18
|
+
CONFIG: 2,
|
|
19
|
+
};
|
|
18
20
|
|
|
19
21
|
function getParamDeclaration(paramName, location, state) {
|
|
20
22
|
const noReloadOnSearch =
|
|
@@ -27,6 +29,7 @@ function getParamDeclaration(paramName, location, state) {
|
|
|
27
29
|
);
|
|
28
30
|
return Object.assign(defaultConfig, paramConfig);
|
|
29
31
|
}
|
|
32
|
+
|
|
30
33
|
function unwrapShorthand(cfg) {
|
|
31
34
|
cfg = isShorthand(cfg) ? { value: cfg } : cfg;
|
|
32
35
|
getStaticDefaultValue["__cacheable"] = true;
|
|
@@ -36,6 +39,7 @@ function unwrapShorthand(cfg) {
|
|
|
36
39
|
const $$fn = isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue;
|
|
37
40
|
return Object.assign(cfg, { $$fn });
|
|
38
41
|
}
|
|
42
|
+
|
|
39
43
|
function getType(cfg, urlType, location, id, paramTypes) {
|
|
40
44
|
if (cfg.type && urlType && urlType.name !== "string")
|
|
41
45
|
throw new Error(`Param '${id}' has two type configurations.`);
|
|
@@ -60,6 +64,7 @@ function getType(cfg, urlType, location, id, paramTypes) {
|
|
|
60
64
|
}
|
|
61
65
|
return cfg.type instanceof ParamType ? cfg.type : paramTypes.type(cfg.type);
|
|
62
66
|
}
|
|
67
|
+
|
|
63
68
|
/** returns false, true, or the squash value to indicate the "default parameter url squash policy". */
|
|
64
69
|
function getSquashPolicy(config, isOptional, defaultPolicy) {
|
|
65
70
|
const squash = config.squash;
|
|
@@ -70,6 +75,7 @@ function getSquashPolicy(config, isOptional, defaultPolicy) {
|
|
|
70
75
|
`Invalid squash policy: '${squash}'. Valid policies: false, true, or arbitrary string`,
|
|
71
76
|
);
|
|
72
77
|
}
|
|
78
|
+
|
|
73
79
|
function getReplace(config, arrayMode, isOptional, squash) {
|
|
74
80
|
const defaultPolicy = [
|
|
75
81
|
{ from: "", to: isOptional || arrayMode ? undefined : "" },
|
|
@@ -83,7 +89,16 @@ function getReplace(config, arrayMode, isOptional, squash) {
|
|
|
83
89
|
(item) => configuredKeys.indexOf(item.from) === -1,
|
|
84
90
|
).concat(replace);
|
|
85
91
|
}
|
|
92
|
+
|
|
86
93
|
export class Param {
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @param {*} id
|
|
97
|
+
* @param {*} type
|
|
98
|
+
* @param {DefType} location
|
|
99
|
+
* @param {import("../url/url-config.js").UrlConfigProvider} urlConfig
|
|
100
|
+
* @param {*} state
|
|
101
|
+
*/
|
|
87
102
|
constructor(id, type, location, urlConfig, state) {
|
|
88
103
|
const config = getParamDeclaration(id, location, state);
|
|
89
104
|
type = getType(config, type, location, id, urlConfig.paramTypes);
|
package/src/router/router.html
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
<script src="/jasmine/boot1.js"></script>
|
|
14
14
|
<script type="module" src="/src/router/services.spec.js"></script>
|
|
15
15
|
<script type="module" src="/src/router/state-filter.spec.js"></script>
|
|
16
|
-
<script type="module" src="/src/router/template-factory.spec.js"></script>
|
|
17
16
|
<script type="module" src="/src/router/view-hook.spec.js"></script>
|
|
18
17
|
<script type="module" src="/src/router/view-scroll.spec.js"></script>
|
|
19
18
|
</head>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { test, expect } from "@playwright/test";
|
|
2
2
|
|
|
3
|
-
const TEST_URL = "src/router/router.html";
|
|
3
|
+
const TEST_URL = "src/router/router.html?random=false";
|
|
4
4
|
|
|
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(4000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Angular } from "../loader.js";
|
|
2
|
+
import { dealoc } from "../shared/dom.js";
|
|
2
3
|
|
|
3
4
|
describe("router services", () => {
|
|
4
5
|
let providers;
|
|
5
6
|
let $injector;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
9
|
+
dealoc(document.getElementById("app"));
|
|
8
10
|
window["angular"] = new Angular();
|
|
9
11
|
let module = window["angular"].module("defaultModule", []);
|
|
10
12
|
module.config(
|
|
@@ -70,6 +70,9 @@ function getNavigableBuilder(isRoot) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {import("../params/param-factory.js").ParamFactory} paramFactory
|
|
75
|
+
*/
|
|
73
76
|
function getParamsBuilder(paramFactory) {
|
|
74
77
|
return function (state) {
|
|
75
78
|
const makeConfigParam = (_config, id) =>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StateBuilder } from "./state-builder.js";
|
|
2
2
|
import { Angular } from "../../loader.js";
|
|
3
|
+
import { dealoc } from "../../shared/dom.js";
|
|
3
4
|
|
|
4
5
|
// TODO refactor this to url service as it is using the provider right now
|
|
5
6
|
describe("StateBuilder", function () {
|
|
@@ -8,6 +9,7 @@ describe("StateBuilder", function () {
|
|
|
8
9
|
let $stateRegistry;
|
|
9
10
|
|
|
10
11
|
beforeEach(function () {
|
|
12
|
+
dealoc(document.getElementById("app"));
|
|
11
13
|
window.angular = new Angular();
|
|
12
14
|
window.angular.module("default", []);
|
|
13
15
|
let $injector = window.angular.bootstrap(document.getElementById("app"), [
|