@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,38 @@
|
|
|
1
|
+
import { dealoc } from "../../../src/jqLite";
|
|
2
|
+
import { publishExternalAPI } from "../../../src/public";
|
|
3
|
+
import { createInjector } from "../../../src/injector";
|
|
4
|
+
|
|
5
|
+
describe("ngClick", () => {
|
|
6
|
+
let element;
|
|
7
|
+
let $compile;
|
|
8
|
+
let $rootScope;
|
|
9
|
+
let injector;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
publishExternalAPI();
|
|
13
|
+
injector = createInjector(["ng"]);
|
|
14
|
+
$compile = injector.get("$compile");
|
|
15
|
+
$rootScope = injector.get("$rootScope");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
dealoc(element);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should get called on a click", () => {
|
|
23
|
+
element = $compile('<div ng-click="clicked = true"></div>')($rootScope);
|
|
24
|
+
$rootScope.$digest();
|
|
25
|
+
expect($rootScope.clicked).toBeFalsy();
|
|
26
|
+
|
|
27
|
+
element[0].click();
|
|
28
|
+
expect($rootScope.clicked).toEqual(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should pass event object", () => {
|
|
32
|
+
element = $compile('<div ng-click="event = $event"></div>')($rootScope);
|
|
33
|
+
$rootScope.$digest();
|
|
34
|
+
|
|
35
|
+
element[0].click();
|
|
36
|
+
expect($rootScope.event).toBeDefined();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { dealoc, jqLite } from "../../../src/jqLite";
|
|
2
|
+
import { setupModuleLoader } from "../../../src/loader";
|
|
3
|
+
import { publishExternalAPI } from "../../../src/public";
|
|
4
|
+
import { createInjector } from "../../../src/injector";
|
|
5
|
+
|
|
6
|
+
describe("ngCloak", () => {
|
|
7
|
+
let element;
|
|
8
|
+
let $compile;
|
|
9
|
+
let $rootScope;
|
|
10
|
+
let injector;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
setupModuleLoader(window);
|
|
14
|
+
publishExternalAPI();
|
|
15
|
+
injector = createInjector(["ng"]);
|
|
16
|
+
$compile = injector.get("$compile");
|
|
17
|
+
$rootScope = injector.get("$rootScope");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
dealoc(element);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should get removed when an element is compiled", () => {
|
|
25
|
+
element = jqLite("<div ng-cloak></div>");
|
|
26
|
+
expect(element.attr("ng-cloak")).toBe("");
|
|
27
|
+
$compile(element);
|
|
28
|
+
expect(element.attr("ng-cloak")).toBeUndefined();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should remove ngCloak class from a compiled element with attribute", () => {
|
|
32
|
+
element = jqLite('<div ng-cloak class="foo ng-cloak bar"></div>');
|
|
33
|
+
|
|
34
|
+
expect(element[0].classList.contains("foo")).toBe(true);
|
|
35
|
+
expect(element[0].classList.contains("ng-cloak")).toBe(true);
|
|
36
|
+
expect(element[0].classList.contains("bar")).toBe(true);
|
|
37
|
+
|
|
38
|
+
$compile(element);
|
|
39
|
+
|
|
40
|
+
expect(element[0].classList.contains("foo")).toBe(true);
|
|
41
|
+
expect(element[0].classList.contains("ng-cloak")).toBe(false);
|
|
42
|
+
expect(element[0].classList.contains("bar")).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { publishExternalAPI } from "../../../src/public";
|
|
2
|
+
import { createInjector } from "../../../src/injector";
|
|
3
|
+
import { dealoc, jqLite } from "../../../src/jqLite";
|
|
4
|
+
import { bind } from "../../../src/core/utils";
|
|
5
|
+
import { Angular } from "../../../src/loader";
|
|
6
|
+
|
|
7
|
+
describe("ngController", () => {
|
|
8
|
+
let angular;
|
|
9
|
+
let element;
|
|
10
|
+
let injector;
|
|
11
|
+
let $rootScope;
|
|
12
|
+
let $compile;
|
|
13
|
+
|
|
14
|
+
const Greeter = function ($scope) {
|
|
15
|
+
// private stuff (not exported to scope)
|
|
16
|
+
this.prefix = "Hello ";
|
|
17
|
+
|
|
18
|
+
// public stuff (exported to scope)
|
|
19
|
+
const ctrl = this;
|
|
20
|
+
$scope.name = "Misko";
|
|
21
|
+
$scope.expr = "Vojta";
|
|
22
|
+
$scope.greet = function (name) {
|
|
23
|
+
return ctrl.prefix + name + ctrl.suffix;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
$scope.protoGreet = bind(this, this.protoGreet);
|
|
27
|
+
};
|
|
28
|
+
Greeter.prototype = {
|
|
29
|
+
suffix: "!",
|
|
30
|
+
protoGreet(name) {
|
|
31
|
+
return this.prefix + name + this.suffix;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
angular = new Angular();
|
|
37
|
+
publishExternalAPI();
|
|
38
|
+
injector = createInjector([
|
|
39
|
+
"ng",
|
|
40
|
+
($controllerProvider) => {
|
|
41
|
+
$controllerProvider.register("PublicModule", function () {
|
|
42
|
+
this.mark = "works";
|
|
43
|
+
});
|
|
44
|
+
$controllerProvider.register("Greeter", Greeter);
|
|
45
|
+
|
|
46
|
+
$controllerProvider.register("Child", ($scope) => {
|
|
47
|
+
$scope.name = "Adam";
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
$controllerProvider.register("Public", function ($scope) {
|
|
51
|
+
this.mark = "works";
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const Foo = function ($scope) {
|
|
55
|
+
$scope.mark = "foo";
|
|
56
|
+
};
|
|
57
|
+
$controllerProvider.register("BoundFoo", ["$scope", Foo.bind(null)]);
|
|
58
|
+
},
|
|
59
|
+
]).invoke((_$rootScope_, _$compile_) => {
|
|
60
|
+
$rootScope = _$rootScope_;
|
|
61
|
+
$compile = _$compile_;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
afterEach(() => {
|
|
66
|
+
dealoc(element);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should instantiate controller and bind methods", () => {
|
|
70
|
+
element = $compile('<div ng-controller="Greeter">{{greet(name)}}</div>')(
|
|
71
|
+
$rootScope,
|
|
72
|
+
);
|
|
73
|
+
$rootScope.$digest();
|
|
74
|
+
expect(element.text()).toBe("Hello Misko!");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should instantiate bound constructor functions", () => {
|
|
78
|
+
element = $compile('<div ng-controller="BoundFoo">{{mark}}</div>')(
|
|
79
|
+
$rootScope,
|
|
80
|
+
);
|
|
81
|
+
$rootScope.$digest();
|
|
82
|
+
expect(element.text()).toBe("foo");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should publish controller into scope", () => {
|
|
86
|
+
element = $compile('<div ng-controller="Public as p">{{p.mark}}</div>')(
|
|
87
|
+
$rootScope,
|
|
88
|
+
);
|
|
89
|
+
$rootScope.$digest();
|
|
90
|
+
expect(element.text()).toBe("works");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("should publish controller into scope from module", () => {
|
|
94
|
+
element = $compile(
|
|
95
|
+
'<div ng-controller="PublicModule as p">{{p.mark}}</div>',
|
|
96
|
+
)($rootScope);
|
|
97
|
+
$rootScope.$digest();
|
|
98
|
+
expect(element.text()).toBe("works");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should allow nested controllers", () => {
|
|
102
|
+
element = $compile(
|
|
103
|
+
'<div ng-controller="Greeter"><div ng-controller="Child">{{greet(name)}}</div></div>',
|
|
104
|
+
)($rootScope);
|
|
105
|
+
$rootScope.$digest();
|
|
106
|
+
expect(element.text()).toBe("Hello Adam!");
|
|
107
|
+
dealoc(element);
|
|
108
|
+
|
|
109
|
+
element = $compile(
|
|
110
|
+
'<div ng-controller="Greeter"><div ng-controller="Child">{{protoGreet(name)}}</div></div>',
|
|
111
|
+
)($rootScope);
|
|
112
|
+
$rootScope.$digest();
|
|
113
|
+
expect(element.text()).toBe("Hello Adam!");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("should instantiate controller defined on scope", () => {
|
|
117
|
+
$rootScope.VojtaGreeter = function ($scope) {
|
|
118
|
+
$scope.name = "Vojta";
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
element = $compile('<div ng-controller="VojtaGreeter">{{name}}</div>')(
|
|
122
|
+
$rootScope,
|
|
123
|
+
);
|
|
124
|
+
$rootScope.$digest();
|
|
125
|
+
expect(element.text()).toBe("Vojta");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("should work with ngInclude on the same element", (done) => {
|
|
129
|
+
element = jqLite(
|
|
130
|
+
'<div><div ng-controller="Greeter" ng-include="\'/mock/interpolation\'"></div></div>',
|
|
131
|
+
);
|
|
132
|
+
window.angular
|
|
133
|
+
.module("myModule", [])
|
|
134
|
+
.controller("Greeter", function GreeterController($scope) {
|
|
135
|
+
$scope.expr = "Vojta";
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
injector = angular.bootstrap(element, ["myModule"]);
|
|
139
|
+
|
|
140
|
+
$rootScope = injector.get("$rootScope");
|
|
141
|
+
$rootScope.$digest();
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
expect(element.text()).toEqual("Vojta");
|
|
144
|
+
dealoc($rootScope);
|
|
145
|
+
done();
|
|
146
|
+
}, 200);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("should only instantiate the controller once with ngInclude on the same element", () => {
|
|
150
|
+
let count = 0;
|
|
151
|
+
|
|
152
|
+
element = jqLite(
|
|
153
|
+
'<div><div ng-controller="Count" ng-include="\'/mock/interpolation\'"></div></div>',
|
|
154
|
+
);
|
|
155
|
+
window.angular
|
|
156
|
+
.module("myModule", [])
|
|
157
|
+
.controller("Count", function CountController($scope) {
|
|
158
|
+
count += 1;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
injector = angular.bootstrap(element, ["myModule"]);
|
|
162
|
+
|
|
163
|
+
$rootScope = injector.get("$rootScope");
|
|
164
|
+
|
|
165
|
+
$rootScope.expr = "first";
|
|
166
|
+
$rootScope.$digest();
|
|
167
|
+
|
|
168
|
+
$rootScope.expr = "second";
|
|
169
|
+
$rootScope.$digest();
|
|
170
|
+
|
|
171
|
+
expect(count).toBe(1);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("when ngInclude is on the same element, the content included content should get a child scope of the controller", () => {
|
|
175
|
+
let controllerScope;
|
|
176
|
+
|
|
177
|
+
element = jqLite(
|
|
178
|
+
'<div><div ng-controller="ExposeScope" ng-include="\'/mock/scopeinit\'"></div></div>',
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
window.angular
|
|
182
|
+
.module("myModule", [])
|
|
183
|
+
.controller("ExposeScope", function ExposeScopeController($scope) {
|
|
184
|
+
controllerScope = $scope;
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
injector = angular.bootstrap(element, ["myModule"]);
|
|
188
|
+
|
|
189
|
+
$rootScope = injector.get("$rootScope");
|
|
190
|
+
$rootScope.$digest();
|
|
191
|
+
|
|
192
|
+
expect(controllerScope.name).toBeUndefined();
|
|
193
|
+
});
|
|
194
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { publishExternalAPI } from "../../../src/public";
|
|
2
|
+
import { createInjector } from "../../../src/injector";
|
|
3
|
+
import { dealoc, jqLite } from "../../../src/jqLite";
|
|
4
|
+
|
|
5
|
+
describe("style", () => {
|
|
6
|
+
let $rootScope;
|
|
7
|
+
let $compile;
|
|
8
|
+
let element;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
publishExternalAPI();
|
|
12
|
+
createInjector(["ng"]).invoke((_$rootScope_, _$compile_) => {
|
|
13
|
+
$rootScope = _$rootScope_;
|
|
14
|
+
$compile = _$compile_;
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
dealoc(element);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should compile style element without binding", () => {
|
|
23
|
+
element = jqLite(
|
|
24
|
+
'<style type="text/css">.header{font-size:1.5em; h3{font-size:1.5em}}</style>',
|
|
25
|
+
);
|
|
26
|
+
$compile(element)($rootScope);
|
|
27
|
+
$rootScope.$digest();
|
|
28
|
+
|
|
29
|
+
expect(element[0].innerHTML).toBe(
|
|
30
|
+
".header{font-size:1.5em; h3{font-size:1.5em}}",
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should compile style element with one simple bind", () => {
|
|
35
|
+
element = jqLite(
|
|
36
|
+
'<style type="text/css">.some-container{ width: {{elementWidth}}px; }</style>',
|
|
37
|
+
);
|
|
38
|
+
$compile(element)($rootScope);
|
|
39
|
+
$rootScope.$digest();
|
|
40
|
+
|
|
41
|
+
expect(element[0].innerHTML).toBe(".some-container{ width: px; }");
|
|
42
|
+
|
|
43
|
+
$rootScope.$apply(() => {
|
|
44
|
+
$rootScope.elementWidth = 200;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(element[0].innerHTML).toBe(".some-container{ width: 200px; }");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should compile style element with one bind", () => {
|
|
51
|
+
element = jqLite(
|
|
52
|
+
'<style type="text/css">.header{ h3 { font-size: {{fontSize}}em }}</style>',
|
|
53
|
+
);
|
|
54
|
+
$compile(element)($rootScope);
|
|
55
|
+
$rootScope.$digest();
|
|
56
|
+
|
|
57
|
+
expect(element[0].innerHTML).toBe(".header{ h3 { font-size: em }}");
|
|
58
|
+
|
|
59
|
+
$rootScope.$apply(() => {
|
|
60
|
+
$rootScope.fontSize = 1.5;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
expect(element[0].innerHTML).toBe(".header{ h3 { font-size: 1.5em }}");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should compile style element with two binds", () => {
|
|
67
|
+
element = jqLite(
|
|
68
|
+
'<style type="text/css">.header{ h3 { font-size: {{fontSize}}{{unit}} }}</style>',
|
|
69
|
+
);
|
|
70
|
+
$compile(element)($rootScope);
|
|
71
|
+
$rootScope.$digest();
|
|
72
|
+
|
|
73
|
+
expect(element[0].innerHTML).toBe(".header{ h3 { font-size: }}");
|
|
74
|
+
|
|
75
|
+
$rootScope.$apply(() => {
|
|
76
|
+
$rootScope.fontSize = 1.5;
|
|
77
|
+
$rootScope.unit = "em";
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(element[0].innerHTML).toBe(".header{ h3 { font-size: 1.5em }}");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should compile content of element with style attr", () => {
|
|
84
|
+
element = jqLite('<div style="some">{{bind}}</div>');
|
|
85
|
+
$compile(element)($rootScope);
|
|
86
|
+
$rootScope.$apply(() => {
|
|
87
|
+
$rootScope.bind = "value";
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(element.text()).toBe("value");
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { publishExternalAPI } from "../../../src/public";
|
|
2
|
+
import { createInjector } from "../../../src/injector";
|
|
3
|
+
import { dealoc } from "../../../src/jqLite";
|
|
4
|
+
import { Angular } from "../../../src/loader";
|
|
5
|
+
|
|
6
|
+
describe("event directives", () => {
|
|
7
|
+
let angular;
|
|
8
|
+
let element;
|
|
9
|
+
let injector;
|
|
10
|
+
let $rootScope;
|
|
11
|
+
let $compile;
|
|
12
|
+
let logs = [];
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
angular = new Angular();
|
|
16
|
+
publishExternalAPI().decorator("$exceptionHandler", function () {
|
|
17
|
+
return (exception, cause) => {
|
|
18
|
+
logs.push(exception.message);
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
injector = createInjector(["ng"]).invoke((_$rootScope_, _$compile_) => {
|
|
22
|
+
$rootScope = _$rootScope_;
|
|
23
|
+
$compile = _$compile_;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
dealoc(element);
|
|
29
|
+
logs = [];
|
|
30
|
+
document.getElementById("dummy").innerHTML = "";
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("ngSubmit", () => {
|
|
34
|
+
it("should get called on form submit", () => {
|
|
35
|
+
element = $compile(
|
|
36
|
+
'<form ng-submit="submitted = true">' +
|
|
37
|
+
'<input type="submit" />' +
|
|
38
|
+
"</form>",
|
|
39
|
+
)($rootScope);
|
|
40
|
+
$rootScope.$digest();
|
|
41
|
+
|
|
42
|
+
// Support: Chrome 60+
|
|
43
|
+
// We need to add the form to the DOM in order for `submit` events to be properly fired.
|
|
44
|
+
document.getElementById("dummy").appendChild(element[0]);
|
|
45
|
+
|
|
46
|
+
// prevent submit within the test harness
|
|
47
|
+
element[0].addEventListener("submit", (e) => {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect($rootScope.submitted).toBeUndefined();
|
|
52
|
+
|
|
53
|
+
element[0].dispatchEvent(new Event("submit"));
|
|
54
|
+
expect($rootScope.submitted).toEqual(true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should expose event on form submit", () => {
|
|
58
|
+
$rootScope.formSubmission = function (e) {
|
|
59
|
+
if (e) {
|
|
60
|
+
$rootScope.formSubmitted = "foo";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
element = $compile(
|
|
65
|
+
'<form ng-submit="formSubmission($event)">' +
|
|
66
|
+
'<input type="submit" />' +
|
|
67
|
+
"</form>",
|
|
68
|
+
)($rootScope);
|
|
69
|
+
$rootScope.$digest();
|
|
70
|
+
|
|
71
|
+
// Support: Chrome 60+ (on Windows)
|
|
72
|
+
// We need to add the form to the DOM in order for `submit` events to be properly fired.
|
|
73
|
+
document.getElementById("dummy").appendChild(element[0]);
|
|
74
|
+
|
|
75
|
+
// prevent submit within the test harness
|
|
76
|
+
element[0].addEventListener("submit", (e) => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect($rootScope.formSubmitted).toBeUndefined();
|
|
81
|
+
|
|
82
|
+
element[0].dispatchEvent(new Event("submit"));
|
|
83
|
+
expect($rootScope.formSubmitted).toEqual("foo");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe("focus", () => {
|
|
88
|
+
describe("call the listener asynchronously during $apply", () => {
|
|
89
|
+
it("should call the listener with non isolate scopes", () => {
|
|
90
|
+
let scope = $rootScope.$new();
|
|
91
|
+
element = $compile('<input type="text" ng-focus="focus()">')(scope);
|
|
92
|
+
scope.focus = jasmine.createSpy("focus");
|
|
93
|
+
|
|
94
|
+
scope.$apply(() => {
|
|
95
|
+
element.triggerHandler("focus");
|
|
96
|
+
expect(scope.focus).not.toHaveBeenCalled();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(scope.focus).toHaveBeenCalled();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("should call the listener with isolate scopes", () => {
|
|
103
|
+
let scope = $rootScope.$new(true);
|
|
104
|
+
element = $compile('<input type="text" ng-focus="focus()">')(scope);
|
|
105
|
+
scope.focus = jasmine.createSpy("focus");
|
|
106
|
+
|
|
107
|
+
scope.$apply(() => {
|
|
108
|
+
element.triggerHandler("focus");
|
|
109
|
+
expect(scope.focus).not.toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("should call the listener synchronously inside of $apply if outside of $apply", () => {
|
|
115
|
+
element = $compile(
|
|
116
|
+
'<input type="text" ng-focus="focus()" ng-model="value">',
|
|
117
|
+
)($rootScope);
|
|
118
|
+
$rootScope.focus = jasmine.createSpy("focus").and.callFake(() => {
|
|
119
|
+
$rootScope.value = "newValue";
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
element.triggerHandler("focus");
|
|
123
|
+
|
|
124
|
+
expect($rootScope.focus).toHaveBeenCalled();
|
|
125
|
+
expect(element.val()).toBe("newValue");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe("DOM event object", () => {
|
|
130
|
+
it("should allow access to the $event object", () => {
|
|
131
|
+
const scope = $rootScope.$new();
|
|
132
|
+
element = $compile('<button ng-click="e = $event">BTN</button>')(scope);
|
|
133
|
+
element.triggerHandler("click");
|
|
134
|
+
expect(scope.e.target).toBe(element[0]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe("blur", () => {
|
|
139
|
+
describe("call the listener asynchronously during $apply", () => {
|
|
140
|
+
it("should call the listener with non isolate scopes", () => {
|
|
141
|
+
const scope = $rootScope.$new();
|
|
142
|
+
element = $compile('<input type="text" ng-blur="blur()">')(scope);
|
|
143
|
+
scope.blur = jasmine.createSpy("blur");
|
|
144
|
+
|
|
145
|
+
scope.$apply(() => {
|
|
146
|
+
element.triggerHandler("blur");
|
|
147
|
+
expect(scope.blur).not.toHaveBeenCalled();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(scope.blur).toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("should call the listener with isolate scopes", () => {
|
|
154
|
+
const scope = $rootScope.$new(true);
|
|
155
|
+
element = $compile('<input type="text" ng-blur="blur()">')(scope);
|
|
156
|
+
scope.blur = jasmine.createSpy("blur");
|
|
157
|
+
|
|
158
|
+
scope.$apply(() => {
|
|
159
|
+
element.triggerHandler("blur");
|
|
160
|
+
expect(scope.blur).not.toHaveBeenCalled();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
expect(scope.blur).toHaveBeenCalled();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("should call the listener synchronously inside of $apply if outside of $apply", () => {
|
|
168
|
+
element = $compile(
|
|
169
|
+
'<input type="text" ng-blur="blur()" ng-model="value">',
|
|
170
|
+
)($rootScope);
|
|
171
|
+
$rootScope.blur = jasmine.createSpy("blur").and.callFake(() => {
|
|
172
|
+
$rootScope.value = "newValue";
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
element.triggerHandler("blur");
|
|
176
|
+
|
|
177
|
+
expect($rootScope.blur).toHaveBeenCalled();
|
|
178
|
+
expect(element.val()).toBe("newValue");
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("should call the listener synchronously if the event is triggered inside of a digest", () => {
|
|
183
|
+
let watchedVal;
|
|
184
|
+
|
|
185
|
+
element = $compile(
|
|
186
|
+
'<button type="button" ng-click="click()">Button</button>',
|
|
187
|
+
)($rootScope);
|
|
188
|
+
$rootScope.$watch("value", (newValue) => {
|
|
189
|
+
watchedVal = newValue;
|
|
190
|
+
});
|
|
191
|
+
$rootScope.click = jasmine.createSpy("click").and.callFake(() => {
|
|
192
|
+
$rootScope.value = "newValue";
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
$rootScope.$apply(() => {
|
|
196
|
+
element.triggerHandler("click");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
expect($rootScope.click).toHaveBeenCalled();
|
|
200
|
+
expect(watchedVal).toEqual("newValue");
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("should call the listener synchronously if the event is triggered outside of a digest", () => {
|
|
204
|
+
let watchedVal;
|
|
205
|
+
|
|
206
|
+
element = $compile(
|
|
207
|
+
'<button type="button" ng-click="click()">Button</button>',
|
|
208
|
+
)($rootScope);
|
|
209
|
+
$rootScope.$watch("value", (newValue) => {
|
|
210
|
+
watchedVal = newValue;
|
|
211
|
+
});
|
|
212
|
+
$rootScope.click = jasmine.createSpy("click").and.callFake(() => {
|
|
213
|
+
$rootScope.value = "newValue";
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
element.triggerHandler("click");
|
|
217
|
+
|
|
218
|
+
expect($rootScope.click).toHaveBeenCalled();
|
|
219
|
+
expect(watchedVal).toEqual("newValue");
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("throwing errors in event handlers", () => {
|
|
223
|
+
it("should not stop execution if the event is triggered outside a digest", () => {
|
|
224
|
+
element = $compile('<button ng-click="click()">Click</button>')(
|
|
225
|
+
$rootScope,
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
$rootScope.click = function () {
|
|
229
|
+
throw new Error("listener error");
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
$rootScope.do = function () {
|
|
233
|
+
element[0].click();
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
$rootScope.do();
|
|
237
|
+
|
|
238
|
+
expect(logs).toEqual(["listener error"]);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("should not stop execution if the event is triggered inside a digest", () => {
|
|
242
|
+
element = $compile('<button ng-click="click()">Click</button>')(
|
|
243
|
+
$rootScope,
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
$rootScope.click = function () {
|
|
247
|
+
throw new Error("listener error");
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
$rootScope.do = function () {
|
|
251
|
+
element.triggerHandler("click");
|
|
252
|
+
logs.push("done");
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
$rootScope.$apply(() => {
|
|
256
|
+
$rootScope.do();
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
expect(logs[0]).toEqual("listener error");
|
|
260
|
+
expect(logs[1]).toEqual("done");
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("should not stop execution if the event is triggered in a watch expression function", () => {
|
|
264
|
+
element = $compile('<button ng-click="click()">Click</button>')(
|
|
265
|
+
$rootScope,
|
|
266
|
+
);
|
|
267
|
+
$rootScope.click = function () {
|
|
268
|
+
throw new Error("listener error");
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
$rootScope.$watch(() => {
|
|
272
|
+
element[0].click();
|
|
273
|
+
logs.push("done");
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
$rootScope.$digest();
|
|
277
|
+
|
|
278
|
+
expect(logs[0]).toEqual("listener error");
|
|
279
|
+
expect(logs[1]).toEqual("done");
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
});
|