@angular-wave/angular.ts 0.0.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/.eslintignore +1 -0
- package/.eslintrc.cjs +29 -0
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +17974 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +246 -0
- package/DEVELOPERS.md +488 -0
- package/LICENSE +22 -0
- package/Makefile +31 -0
- package/README.md +115 -0
- package/RELEASE.md +98 -0
- package/SECURITY.md +16 -0
- package/TRIAGING.md +135 -0
- package/css/angular.css +22 -0
- package/dist/angular-ts.cjs.js +36843 -0
- package/dist/angular-ts.esm.js +36841 -0
- package/dist/angular-ts.umd.js +36848 -0
- package/dist/build/angular-animate.js +4272 -0
- package/dist/build/angular-aria.js +426 -0
- package/dist/build/angular-message-format.js +1072 -0
- package/dist/build/angular-messages.js +829 -0
- package/dist/build/angular-mocks.js +3757 -0
- package/dist/build/angular-parse-ext.js +1275 -0
- package/dist/build/angular-resource.js +911 -0
- package/dist/build/angular-route.js +1266 -0
- package/dist/build/angular-sanitize.js +891 -0
- package/dist/build/angular-touch.js +368 -0
- package/dist/build/angular.js +36600 -0
- package/e2e/unit.spec.ts +15 -0
- 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 +1 -0
- package/index.html +104 -0
- package/package.json +47 -0
- package/playwright.config.ts +78 -0
- package/public/circle.html +1 -0
- package/public/my_child_directive.html +1 -0
- package/public/my_directive.html +1 -0
- package/public/my_other_directive.html +1 -0
- package/public/test.html +1 -0
- package/rollup.config.js +31 -0
- package/src/animations/animateCache.js +55 -0
- package/src/animations/animateChildrenDirective.js +105 -0
- package/src/animations/animateCss.js +1139 -0
- package/src/animations/animateCssDriver.js +291 -0
- package/src/animations/animateJs.js +367 -0
- package/src/animations/animateJsDriver.js +67 -0
- package/src/animations/animateQueue.js +851 -0
- package/src/animations/animation.js +506 -0
- package/src/animations/module.js +779 -0
- package/src/animations/ngAnimateSwap.js +119 -0
- package/src/animations/rafScheduler.js +50 -0
- package/src/animations/shared.js +378 -0
- package/src/constants.js +20 -0
- package/src/core/animate.js +845 -0
- package/src/core/animateCss.js +73 -0
- package/src/core/animateRunner.js +195 -0
- package/src/core/attributes.js +199 -0
- package/src/core/cache.js +45 -0
- package/src/core/compile.js +4727 -0
- package/src/core/controller.js +225 -0
- package/src/core/exceptionHandler.js +63 -0
- package/src/core/filter.js +146 -0
- package/src/core/interpolate.js +442 -0
- package/src/core/interval.js +188 -0
- package/src/core/intervalFactory.js +57 -0
- package/src/core/location.js +1086 -0
- package/src/core/parser/parse.js +2562 -0
- package/src/core/parser/parse.md +13 -0
- package/src/core/q.js +746 -0
- package/src/core/rootScope.js +1596 -0
- package/src/core/sanitizeUri.js +85 -0
- package/src/core/sce.js +1161 -0
- package/src/core/taskTrackerFactory.js +125 -0
- package/src/core/timeout.js +121 -0
- package/src/core/urlUtils.js +187 -0
- package/src/core/utils.js +1349 -0
- package/src/directive/a.js +37 -0
- package/src/directive/attrs.js +283 -0
- package/src/directive/bind.js +51 -0
- package/src/directive/bind.md +142 -0
- package/src/directive/change.js +12 -0
- package/src/directive/change.md +25 -0
- package/src/directive/cloak.js +12 -0
- package/src/directive/cloak.md +24 -0
- package/src/directive/events.js +75 -0
- package/src/directive/events.md +166 -0
- package/src/directive/form.js +725 -0
- package/src/directive/init.js +15 -0
- package/src/directive/init.md +41 -0
- package/src/directive/input.js +1783 -0
- package/src/directive/list.js +46 -0
- package/src/directive/list.md +22 -0
- package/src/directive/ngClass.js +249 -0
- package/src/directive/ngController.js +64 -0
- package/src/directive/ngCsp.js +82 -0
- package/src/directive/ngIf.js +134 -0
- package/src/directive/ngInclude.js +217 -0
- package/src/directive/ngModel.js +1356 -0
- package/src/directive/ngModelOptions.js +509 -0
- package/src/directive/ngOptions.js +670 -0
- package/src/directive/ngRef.js +90 -0
- package/src/directive/ngRepeat.js +650 -0
- package/src/directive/ngShowHide.js +255 -0
- package/src/directive/ngSwitch.js +178 -0
- package/src/directive/ngTransclude.js +98 -0
- package/src/directive/non-bindable.js +11 -0
- package/src/directive/non-bindable.md +17 -0
- package/src/directive/script.js +30 -0
- package/src/directive/select.js +624 -0
- package/src/directive/style.js +25 -0
- package/src/directive/style.md +23 -0
- package/src/directive/validators.js +329 -0
- package/src/exts/aria.js +544 -0
- package/src/exts/messages.js +852 -0
- package/src/filters/filter.js +207 -0
- package/src/filters/filter.md +69 -0
- package/src/filters/filters.js +239 -0
- package/src/filters/json.md +16 -0
- package/src/filters/limit-to.js +43 -0
- package/src/filters/limit-to.md +19 -0
- package/src/filters/order-by.js +183 -0
- package/src/filters/order-by.md +83 -0
- package/src/index.js +13 -0
- package/src/injector.js +1034 -0
- package/src/jqLite.js +1117 -0
- package/src/loader.js +1320 -0
- package/src/public.js +215 -0
- package/src/routeToRegExp.js +41 -0
- package/src/services/anchorScroll.js +135 -0
- package/src/services/browser.js +321 -0
- package/src/services/cacheFactory.js +398 -0
- package/src/services/cookieReader.js +72 -0
- package/src/services/document.js +64 -0
- package/src/services/http.js +1537 -0
- package/src/services/httpBackend.js +206 -0
- package/src/services/log.js +160 -0
- package/src/services/templateRequest.js +139 -0
- package/test/angular.spec.js +2153 -0
- package/test/aria/aria.spec.js +1245 -0
- package/test/binding.spec.js +504 -0
- package/test/build-test.html +14 -0
- package/test/injector.spec.js +2327 -0
- package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
- package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
- package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
- package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
- package/test/jasmine/jasmine-browser.json +17 -0
- package/test/jasmine/jasmine.json +9 -0
- package/test/jqlite.spec.js +2133 -0
- package/test/loader.spec.js +219 -0
- package/test/messages/messages.spec.js +1146 -0
- package/test/min-err.spec.js +174 -0
- package/test/mock-test.html +13 -0
- package/test/module-test.html +15 -0
- package/test/ng/anomate.spec.js +606 -0
- package/test/ng/cache-factor.spec.js +334 -0
- package/test/ng/compile.spec.js +17956 -0
- package/test/ng/controller-provider.spec.js +227 -0
- package/test/ng/cookie-reader.spec.js +98 -0
- package/test/ng/directive/a.spec.js +192 -0
- package/test/ng/directive/bind.spec.js +334 -0
- package/test/ng/directive/boolean.spec.js +136 -0
- package/test/ng/directive/change.spec.js +71 -0
- package/test/ng/directive/class.spec.js +858 -0
- package/test/ng/directive/click.spec.js +38 -0
- package/test/ng/directive/cloak.spec.js +44 -0
- package/test/ng/directive/constoller.spec.js +194 -0
- package/test/ng/directive/element-style.spec.js +92 -0
- package/test/ng/directive/event.spec.js +282 -0
- package/test/ng/directive/form.spec.js +1518 -0
- package/test/ng/directive/href.spec.js +143 -0
- package/test/ng/directive/if.spec.js +402 -0
- package/test/ng/directive/include.spec.js +828 -0
- package/test/ng/directive/init.spec.js +68 -0
- package/test/ng/directive/input.spec.js +3810 -0
- package/test/ng/directive/list.spec.js +170 -0
- package/test/ng/directive/model-options.spec.js +1008 -0
- package/test/ng/directive/model.spec.js +1905 -0
- package/test/ng/directive/non-bindable.spec.js +55 -0
- package/test/ng/directive/options.spec.js +3583 -0
- package/test/ng/directive/ref.spec.js +575 -0
- package/test/ng/directive/repeat.spec.js +1675 -0
- package/test/ng/directive/script.spec.js +52 -0
- package/test/ng/directive/scrset.spec.js +67 -0
- package/test/ng/directive/select.spec.js +2541 -0
- package/test/ng/directive/show-hide.spec.js +253 -0
- package/test/ng/directive/src.spec.js +157 -0
- package/test/ng/directive/style.spec.js +178 -0
- package/test/ng/directive/switch.spec.js +647 -0
- package/test/ng/directive/validators.spec.js +717 -0
- package/test/ng/document.spec.js +52 -0
- package/test/ng/filter/filter.spec.js +714 -0
- package/test/ng/filter/filters.spec.js +35 -0
- package/test/ng/filter/limit-to.spec.js +251 -0
- package/test/ng/filter/order-by.spec.js +891 -0
- package/test/ng/filter.spec.js +149 -0
- package/test/ng/http-backend.spec.js +398 -0
- package/test/ng/http.spec.js +4071 -0
- package/test/ng/interpolate.spec.js +642 -0
- package/test/ng/interval.spec.js +343 -0
- package/test/ng/location.spec.js +3488 -0
- package/test/ng/on.spec.js +229 -0
- package/test/ng/parse.spec.js +4655 -0
- package/test/ng/prop.spec.js +805 -0
- package/test/ng/q.spec.js +2904 -0
- package/test/ng/root-element.spec.js +16 -0
- package/test/ng/sanitize-uri.spec.js +249 -0
- package/test/ng/sce.spec.js +660 -0
- package/test/ng/scope.spec.js +3442 -0
- package/test/ng/template-request.spec.js +236 -0
- package/test/ng/timeout.spec.js +351 -0
- package/test/ng/url-utils.spec.js +156 -0
- package/test/ng/utils.spec.js +144 -0
- package/test/original-test.html +21 -0
- package/test/public.spec.js +34 -0
- package/test/sanitize/bing-html.spec.js +36 -0
- package/test/server/express.js +158 -0
- package/test/test-utils.js +11 -0
- package/tsconfig.json +17 -0
- package/types/angular.d.ts +138 -0
- package/types/global.d.ts +9 -0
- package/types/index.d.ts +2357 -0
- package/types/jqlite.d.ts +558 -0
- package/vite.config.js +14 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
urlResolve,
|
|
3
|
+
urlIsSameOrigin,
|
|
4
|
+
urlIsSameOriginAsBaseUrl,
|
|
5
|
+
urlIsAllowedOriginFactory,
|
|
6
|
+
} from "../../src/core/urlUtils";
|
|
7
|
+
|
|
8
|
+
let $document = window.document;
|
|
9
|
+
|
|
10
|
+
describe("urlUtils", () => {
|
|
11
|
+
describe("urlResolve", () => {
|
|
12
|
+
it("should returned already parsed URLs unchanged", () => {
|
|
13
|
+
const urlObj = urlResolve("/foo?bar=baz#qux");
|
|
14
|
+
expect(urlResolve(urlObj)).toBe(urlObj);
|
|
15
|
+
expect(urlResolve(true)).toBe(true);
|
|
16
|
+
expect(urlResolve(null)).toBeNull();
|
|
17
|
+
expect(urlResolve(undefined)).toBeUndefined();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should normalize a relative url", () => {
|
|
21
|
+
expect(urlResolve("foo").href).toMatch(/^https?:\/\/[^/]+\/foo$/);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should parse relative URL into component pieces", () => {
|
|
25
|
+
const parsed = urlResolve("foo");
|
|
26
|
+
expect(parsed.href).toMatch(/https?:\/\//);
|
|
27
|
+
expect(parsed.protocol).toMatch(/^https?/);
|
|
28
|
+
expect(parsed.host).not.toBe("");
|
|
29
|
+
expect(parsed.hostname).not.toBe("");
|
|
30
|
+
expect(parsed.pathname).not.toBe("");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should return pathname as / if empty path provided", () => {
|
|
34
|
+
// IE (all versions) counts / as empty, necessary to use / so that pathname is not context.html
|
|
35
|
+
const parsed = urlResolve("/");
|
|
36
|
+
expect(parsed.pathname).toBe("/");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should return an IPv6 hostname wrapped in brackets", () => {
|
|
40
|
+
// Support: IE 9-11 only, Edge 16-17 only (fixed in 18 Preview)
|
|
41
|
+
// IE/Edge don't wrap IPv6 addresses' hostnames in square brackets
|
|
42
|
+
// when parsed out of an anchor element.
|
|
43
|
+
const parsed = urlResolve("http://[::1]/");
|
|
44
|
+
expect(parsed.hostname).toBe("[::1]");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should not put the domain in brackets for the hostname field", () => {
|
|
48
|
+
const parsed = urlResolve("https://google.com/");
|
|
49
|
+
expect(parsed.hostname).toBe("google.com");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("urlIsSameOrigin and urlIsSameOriginAsBaseUrl", () => {
|
|
54
|
+
it("should support various combinations of urls - both string and parsed", () => {
|
|
55
|
+
function expectIsSameOrigin(url, expectedValue) {
|
|
56
|
+
expect(urlIsSameOrigin(url)).toBe(expectedValue);
|
|
57
|
+
expect(urlIsSameOrigin(urlResolve(url))).toBe(expectedValue);
|
|
58
|
+
|
|
59
|
+
// urlIsSameOriginAsBaseUrl() should behave the same as urlIsSameOrigin() by default.
|
|
60
|
+
// Behavior when there is a non-default base URL or when the base URL changes dynamically
|
|
61
|
+
// is tested in the end-to-end tests in e2e/tests/base-tag.spec.js.
|
|
62
|
+
expect(urlIsSameOriginAsBaseUrl(url)).toBe(expectedValue);
|
|
63
|
+
expect(urlIsSameOriginAsBaseUrl(urlResolve(url))).toBe(expectedValue);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
expectIsSameOrigin("path", true);
|
|
67
|
+
|
|
68
|
+
const origin = urlResolve($document.location.href);
|
|
69
|
+
expectIsSameOrigin(`//${origin.host}/path`, true);
|
|
70
|
+
|
|
71
|
+
// Different domain.
|
|
72
|
+
expectIsSameOrigin("http://example.com/path", false);
|
|
73
|
+
|
|
74
|
+
// Auto fill protocol.
|
|
75
|
+
expectIsSameOrigin("//example.com/path", false);
|
|
76
|
+
|
|
77
|
+
// Should not match when the ports are different.
|
|
78
|
+
// This assumes that the test is *not* running on port 22 (very unlikely).
|
|
79
|
+
expectIsSameOrigin(`//${origin.hostname}:22/path`, false);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("urlIsAllowedOriginFactory", () => {
|
|
84
|
+
const origin = urlResolve(window.location.href);
|
|
85
|
+
let urlIsAllowedOrigin;
|
|
86
|
+
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
urlIsAllowedOrigin = urlIsAllowedOriginFactory([
|
|
89
|
+
"https://foo.com/",
|
|
90
|
+
`${origin.protocol}://bar.com:1337/`,
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("should implicitly allow the current origin", () => {
|
|
95
|
+
expect(urlIsAllowedOrigin("path")).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("should check against the list of trusted origins", () => {
|
|
99
|
+
expect(urlIsAllowedOrigin("https://foo.com/path")).toBe(true);
|
|
100
|
+
expect(urlIsAllowedOrigin(`${origin.protocol}://bar.com:1337/path`)).toBe(
|
|
101
|
+
true,
|
|
102
|
+
);
|
|
103
|
+
expect(urlIsAllowedOrigin("https://baz.com:1337/path")).toBe(false);
|
|
104
|
+
expect(urlIsAllowedOrigin("https://qux.com/path")).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("should support both strings and parsed URL objects", () => {
|
|
108
|
+
expect(urlIsAllowedOrigin("path")).toBe(true);
|
|
109
|
+
expect(urlIsAllowedOrigin(urlResolve("path"))).toBe(true);
|
|
110
|
+
expect(urlIsAllowedOrigin("https://foo.com/path")).toBe(true);
|
|
111
|
+
expect(urlIsAllowedOrigin(urlResolve("https://foo.com/path"))).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("should return true only if the origins (protocol, hostname, post) match", () => {
|
|
115
|
+
const differentProtocol = origin.protocol !== "http" ? "http" : "https";
|
|
116
|
+
const differentPort = (parseInt(origin.port, 10) || 0) + 1;
|
|
117
|
+
let url;
|
|
118
|
+
|
|
119
|
+
// Relative path
|
|
120
|
+
url = "path";
|
|
121
|
+
expect(urlIsAllowedOrigin(url)).toBe(true);
|
|
122
|
+
|
|
123
|
+
// Same origin
|
|
124
|
+
url = `${origin.protocol}://${origin.host}/path`;
|
|
125
|
+
expect(urlIsAllowedOrigin(url)).toBe(true);
|
|
126
|
+
|
|
127
|
+
// Same origin - implicit protocol
|
|
128
|
+
url = `//${origin.host}/path`;
|
|
129
|
+
expect(urlIsAllowedOrigin(url)).toBe(true);
|
|
130
|
+
|
|
131
|
+
// Same origin - different protocol
|
|
132
|
+
url = `${differentProtocol}://${origin.host}/path`;
|
|
133
|
+
expect(urlIsAllowedOrigin(url)).toBe(false);
|
|
134
|
+
|
|
135
|
+
// Same origin - different port
|
|
136
|
+
url = `${origin.protocol}://${origin.hostname}:${differentPort}/path`;
|
|
137
|
+
expect(urlIsAllowedOrigin(url)).toBe(false);
|
|
138
|
+
|
|
139
|
+
// Allowed origin
|
|
140
|
+
url = `${origin.protocol}://bar.com:1337/path`;
|
|
141
|
+
expect(urlIsAllowedOrigin(url)).toBe(true);
|
|
142
|
+
|
|
143
|
+
// Allowed origin - implicit protocol
|
|
144
|
+
url = "//bar.com:1337/path";
|
|
145
|
+
expect(urlIsAllowedOrigin(url)).toBe(true);
|
|
146
|
+
|
|
147
|
+
// Allowed origin - different protocol
|
|
148
|
+
url = `${differentProtocol}://bar.com:1337/path`;
|
|
149
|
+
expect(urlIsAllowedOrigin(url)).toBe(false);
|
|
150
|
+
|
|
151
|
+
// Allowed origin - different port
|
|
152
|
+
url = `${origin.protocol}://bar.com:1338/path`;
|
|
153
|
+
expect(urlIsAllowedOrigin(url)).toBe(false);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { hashKey } from "../../src/core/utils";
|
|
2
|
+
|
|
3
|
+
describe("api", () => {
|
|
4
|
+
describe("hashKey()", () => {
|
|
5
|
+
it("should use an existing `$$hashKey`", () => {
|
|
6
|
+
const obj = { $$hashKey: "foo" };
|
|
7
|
+
expect(hashKey(obj)).toBe("foo");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should support a function as `$$hashKey` (and call it)", () => {
|
|
11
|
+
const obj = { $$hashKey: () => "foo" };
|
|
12
|
+
expect(hashKey(obj)).toBe("foo");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should create a new `$$hashKey` if none exists (and return it)", () => {
|
|
16
|
+
const obj = {};
|
|
17
|
+
expect(hashKey(obj)).toBe(obj.$$hashKey);
|
|
18
|
+
expect(obj.$$hashKey).toBeDefined();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should create appropriate `$$hashKey`s for primitive values", () => {
|
|
22
|
+
expect(hashKey(undefined)).toBe(hashKey(undefined));
|
|
23
|
+
expect(hashKey(null)).toBe(hashKey(null));
|
|
24
|
+
expect(hashKey(null)).not.toBe(hashKey(undefined));
|
|
25
|
+
expect(hashKey(true)).toBe(hashKey(true));
|
|
26
|
+
expect(hashKey(false)).toBe(hashKey(false));
|
|
27
|
+
expect(hashKey(false)).not.toBe(hashKey(true));
|
|
28
|
+
expect(hashKey(42)).toBe(hashKey(42));
|
|
29
|
+
expect(hashKey(1337)).toBe(hashKey(1337));
|
|
30
|
+
expect(hashKey(1337)).not.toBe(hashKey(42));
|
|
31
|
+
expect(hashKey("foo")).toBe(hashKey("foo"));
|
|
32
|
+
expect(hashKey("foo")).not.toBe(hashKey("bar"));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should create appropriate `$$hashKey`s for non-primitive values", () => {
|
|
36
|
+
const fn = function () {};
|
|
37
|
+
const arr = [];
|
|
38
|
+
const obj = {};
|
|
39
|
+
const date = new Date();
|
|
40
|
+
|
|
41
|
+
expect(hashKey(fn)).toBe(hashKey(fn));
|
|
42
|
+
expect(hashKey(fn)).not.toBe(hashKey(() => {}));
|
|
43
|
+
expect(hashKey(arr)).toBe(hashKey(arr));
|
|
44
|
+
expect(hashKey(arr)).not.toBe(hashKey([]));
|
|
45
|
+
expect(hashKey(obj)).toBe(hashKey(obj));
|
|
46
|
+
expect(hashKey(obj)).not.toBe(hashKey({}));
|
|
47
|
+
expect(hashKey(date)).toBe(hashKey(date));
|
|
48
|
+
expect(hashKey(date)).not.toBe(hashKey(new Date()));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("is undefined:undefined for undefined", () => {
|
|
52
|
+
expect(hashKey(undefined)).toEqual("undefined:undefined");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("is object:null for null", () => {
|
|
56
|
+
expect(hashKey(null)).toEqual("object:null");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("is boolean:true for true", () => {
|
|
60
|
+
expect(hashKey(true)).toEqual("boolean:true");
|
|
61
|
+
});
|
|
62
|
+
it("is boolean:false for false", () => {
|
|
63
|
+
expect(hashKey(false)).toEqual("boolean:false");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("is number:42 for 42", () => {
|
|
67
|
+
expect(hashKey(42)).toEqual("number:42");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('is string:42 for "42"', () => {
|
|
71
|
+
expect(hashKey("42")).toEqual("string:42");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("is object:[unique id] for objects", () => {
|
|
75
|
+
expect(hashKey({})).toMatch(/^object:\S+$/);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("is the same key when asked for the same object many times", () => {
|
|
79
|
+
const obj = {};
|
|
80
|
+
expect(hashKey(obj)).toEqual(hashKey(obj));
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("does not change when object value changes", () => {
|
|
84
|
+
const obj = { a: 42 };
|
|
85
|
+
const hash1 = hashKey(obj);
|
|
86
|
+
obj.a = 43;
|
|
87
|
+
const hash2 = hashKey(obj);
|
|
88
|
+
expect(hash1).toEqual(hash2);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("is not the same for different objects even with the same value", () => {
|
|
92
|
+
const obj1 = { a: 42 };
|
|
93
|
+
const obj2 = { a: 42 };
|
|
94
|
+
expect(hashKey(obj1)).not.toEqual(hashKey(obj2));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("is function:[unique id] for functions", () => {
|
|
98
|
+
const fn = function (a) {
|
|
99
|
+
return a;
|
|
100
|
+
};
|
|
101
|
+
expect(hashKey(fn)).toMatch(/^function:\S+$/);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("is the same key when asked for the same function many times", () => {
|
|
105
|
+
const fn = () => {};
|
|
106
|
+
expect(hashKey(fn)).toEqual(hashKey(fn));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("is not the same for different identical functions", () => {
|
|
110
|
+
const fn1 = () => {
|
|
111
|
+
return 42;
|
|
112
|
+
};
|
|
113
|
+
const fn2 = () => {
|
|
114
|
+
return 42;
|
|
115
|
+
};
|
|
116
|
+
expect(hashKey(fn1)).not.toEqual(hashKey(fn2));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("stores the hash key in the $$hashKey attribute", () => {
|
|
120
|
+
const obj = { a: 42 };
|
|
121
|
+
const hash = hashKey(obj);
|
|
122
|
+
expect(obj.$$hashKey).toEqual(hash.match(/^object:(\S+)$/)[0]);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("uses preassigned $$hashKey", () => {
|
|
126
|
+
expect(hashKey({ $$hashKey: 42 })).toEqual(42);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("supports a function $$hashKey", function () {
|
|
130
|
+
expect(hashKey({ $$hashKey: () => 42 })).toEqual(42);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("calls the function $$hashKey as a method with the correct this", () => {
|
|
134
|
+
expect(
|
|
135
|
+
hashKey({
|
|
136
|
+
myKey: 42,
|
|
137
|
+
$$hashKey: function () {
|
|
138
|
+
return this.myKey;
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
).toEqual(42);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<script src="../dist/build/angular.js"></script>
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
Test:
|
|
8
|
+
<my-component></my-component>
|
|
9
|
+
{{ 2 + 2 }}
|
|
10
|
+
</body>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
14
|
+
window.angular.module("myModule", []).component("myComponent", {
|
|
15
|
+
template: "<div>ME</div>",
|
|
16
|
+
});
|
|
17
|
+
window.angular.bootstrap(document, ["myModule"]);
|
|
18
|
+
//angularInit(document, window.angular.bootstrap);
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { publishExternalAPI } from "../src/public";
|
|
2
|
+
import { createInjector } from "../src/injector";
|
|
3
|
+
|
|
4
|
+
describe("public", () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
publishExternalAPI();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("sets up the angular object and the module loader", () => {
|
|
10
|
+
expect(window.angular).toBeDefined();
|
|
11
|
+
expect(window.angular.module).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("sets up the ng module", () => {
|
|
15
|
+
expect(createInjector(["ng"])).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("sets up the $filter service", () => {
|
|
19
|
+
const injector = createInjector(["ng"]);
|
|
20
|
+
expect(injector.has("$filter")).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("sets up the $parse service", () => {
|
|
24
|
+
publishExternalAPI();
|
|
25
|
+
const injector = createInjector(["ng"]);
|
|
26
|
+
expect(injector.has("$parse")).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("sets up the $rootScope", () => {
|
|
30
|
+
publishExternalAPI();
|
|
31
|
+
const injector = createInjector(["ng"]);
|
|
32
|
+
expect(injector.has("$rootScope")).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createInjector } from "../../src/injector";
|
|
2
|
+
import { forEach } from "../../src/core/utils";
|
|
3
|
+
import { publishExternalAPI } from "../../src/public";
|
|
4
|
+
|
|
5
|
+
describe("ngBindHtml", () => {
|
|
6
|
+
let $rootScope, $compile;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
publishExternalAPI();
|
|
10
|
+
createInjector(["ng"]).invoke((_$rootScope_, _$compile_) => {
|
|
11
|
+
$rootScope = _$rootScope_;
|
|
12
|
+
$compile = _$compile_;
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should set html", () => {
|
|
17
|
+
const element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
18
|
+
$rootScope.html = "<div>hello</div>";
|
|
19
|
+
$rootScope.$digest();
|
|
20
|
+
expect(element.html()).toEqual("<div>hello</div>");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should reset html when value is null or undefined", () => {
|
|
24
|
+
const element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
25
|
+
|
|
26
|
+
forEach([null, undefined, ""], (val) => {
|
|
27
|
+
$rootScope.html = "some val";
|
|
28
|
+
$rootScope.$digest();
|
|
29
|
+
expect(element.html()).toEqual("some val");
|
|
30
|
+
|
|
31
|
+
$rootScope.html = val;
|
|
32
|
+
$rootScope.$digest();
|
|
33
|
+
expect(element.html()).toEqual("");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
const app = express();
|
|
3
|
+
const port = 3000;
|
|
4
|
+
|
|
5
|
+
app.use("/post", express.json());
|
|
6
|
+
app.use("/nocontent", express.json());
|
|
7
|
+
app.use((req, res, next) => {
|
|
8
|
+
res.header("Access-Control-Allow-Origin", "*"); // Change * to your desired origin if needed
|
|
9
|
+
res.header(
|
|
10
|
+
"Access-Control-Allow-Headers",
|
|
11
|
+
"Origin, X-Requested-With, Content-Type, Accept, Authorization",
|
|
12
|
+
);
|
|
13
|
+
// Additional headers you may need to allow
|
|
14
|
+
|
|
15
|
+
// Set the allowed methods
|
|
16
|
+
if (req.method === "OPTIONS") {
|
|
17
|
+
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE");
|
|
18
|
+
return res.status(200).json({});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
next();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
app.post("/post", (req, res) => {
|
|
25
|
+
console.log(req.body);
|
|
26
|
+
res.json(req.body);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
app.post("/invalidarray", (req, res) => {
|
|
30
|
+
res.json("{1, 2, 3]");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
app.post("/nocontent", (req, res) => {
|
|
34
|
+
console.log(req.body);
|
|
35
|
+
res.removeHeader("Content-type");
|
|
36
|
+
res.json(req.body);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
app.post("/form", (req, res) => {
|
|
40
|
+
res.send(req.body);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
app.post("/blob", (req, res) => {
|
|
44
|
+
res.send(req.body);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
app.head("/head", (req, res) => {
|
|
48
|
+
res.send(req.body);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
app.delete("/delete", (req, res) => {
|
|
52
|
+
res.send(req.body);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
app.put("/put", (req, res) => {
|
|
56
|
+
res.json("Hello");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
app.patch("/patch", (req, res) => {
|
|
60
|
+
res.json("Hello");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
app.post("/hello", (req, res) => {
|
|
64
|
+
res.json("Hello");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
app.get("/interpolation", (req, res) => {
|
|
68
|
+
res.send("{{expr}}");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
app.get("/jsoninterpolation", (req, res) => {
|
|
72
|
+
res.json("{{expr}}");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
app.get("/scopeinit", (req, res) => {
|
|
76
|
+
res.send('<div ng-init="name=1"></div>');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
app.get("/directive", (req, res) => {
|
|
80
|
+
res.send("<div><div test></div></div>");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
app.get("/empty", (req, res) => {
|
|
84
|
+
res.send(" ");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
app.get("/hello", (req, res) => {
|
|
88
|
+
res.send("Hello");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
app.get("/div", (req, res) => {
|
|
92
|
+
res.send("<div>Hello</div>");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
app.get("/divexpr", (req, res) => {
|
|
96
|
+
res.send("<div>{{expr}}</div>");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
app.get("/divctrlexpr", (req, res) => {
|
|
100
|
+
res.send("<div>{{$ctrl.expr}}</div>");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
app.get("/template.html", (req, res) => {
|
|
104
|
+
res.send("<p>template.html</p>");
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
app.get("/circle-svg", (req, res) => {
|
|
108
|
+
res.send("<circle></circle>");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
app.get("/hello2", (req, res) => {
|
|
112
|
+
res.send("Hello2");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
app.get("/third", (req, res) => {
|
|
116
|
+
res.send("<div third>{{1+2}}</div>");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
app.get("/script", (req, res) => {
|
|
120
|
+
res.send("<div><script>window.SCRIPT_RAN = true;</script></div>");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
app.get("/401", (req, res) => {
|
|
124
|
+
res.sendStatus(401);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
app.get("/404", (req, res) => {
|
|
128
|
+
res.sendStatus(404);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
app.get("/never", (req, res) => {
|
|
132
|
+
setTimeout(() => {}, 500);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
app.get("/my-rect.html", (req, res) => {
|
|
136
|
+
res.send("<g ng-include=\"'/mock/include.svg'\"></g>");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
app.get("/my-rect2.html", (req, res) => {
|
|
140
|
+
res.send("<g ng-include=\"'/mock/include.svg'\"><a></a></g>");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
app.get("/include.svg", (req, res) => {
|
|
144
|
+
res.send("<rect></rect><rect></rect>");
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
app.get("/", (req, res) => {
|
|
148
|
+
res.send("Hello");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
app.listen(port, () => {
|
|
152
|
+
console.log(`Example app listening on port ${port}`);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// messageSpec.js
|
|
156
|
+
app.get("/my-messages", (req, res) => {
|
|
157
|
+
res.send('<div ng-message="required">You did not enter a value</div>');
|
|
158
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jqLite } from "../src/jqLite";
|
|
2
|
+
|
|
3
|
+
export function browserTrigger(element, event) {
|
|
4
|
+
jqLite(element)[0].dispatchEvent(
|
|
5
|
+
new Event(event, { bubbles: true, cancelable: true }),
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function wait(t) {
|
|
10
|
+
return new Promise((resolve, _) => setTimeout(resolve, t));
|
|
11
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"checkJs": true,
|
|
5
|
+
"noEmit": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"lib": ["ES2018", "DOM"],
|
|
9
|
+
"target": "ES5",
|
|
10
|
+
"sourceMap": false,
|
|
11
|
+
"declaration": false,
|
|
12
|
+
"incremental": true,
|
|
13
|
+
"typeRoots": ["types/global.d.ts", "node_modules/@types"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["./src/*.js", "./**/*.ts"],
|
|
16
|
+
"exclude": []
|
|
17
|
+
}
|