@angular-wave/angular.ts 0.0.63 → 0.0.65
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/Makefile +6 -2
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/public/jasmine/jasmine-5.1.2/jasmine-html.js +0 -1
- package/src/angular.spec.js +14 -19
- package/src/animations/module.js +2 -2
- package/src/binding.spec.js +7 -4
- package/src/core/animate/animate.spec.js +2 -4
- package/src/core/cache/cache-factory.spec.js +3 -3
- package/src/core/compile/compile.spec.js +66 -60
- package/src/core/controller/controller.spec.js +3 -3
- package/src/core/cookie-reader.spec.js +3 -3
- package/src/core/di/injector.html +18 -0
- package/src/{injector.js → core/di/injector.js} +58 -45
- package/src/{injector.spec.js → core/di/injector.spec.js} +44 -34
- package/src/core/di/injector.test.js +12 -0
- package/src/core/di/ng-module.html +18 -0
- package/src/core/di/ng-module.js +202 -0
- package/src/core/di/ng-module.spec.js +269 -0
- package/src/core/di/ng-module.test.js +12 -0
- package/src/core/filter/filter.spec.js +5 -5
- package/src/core/interpolate/interpolate.spec.js +3 -3
- package/src/core/interval/interval.spec.js +11 -8
- package/src/core/location/location.spec.js +3 -3
- package/src/core/on.spec.js +3 -3
- package/src/core/parser/lexer.spec.js +12 -9
- package/src/core/parser/parse.spec.js +12 -9
- package/src/core/prop.spec.js +48 -36
- package/src/core/q/q.spec.js +7 -10
- package/src/core/q/q.test.js +12 -0
- package/src/core/root-element.spec.js +0 -2
- package/src/core/sce/sce.spec.js +8 -7
- package/src/core/scope/scope.js +0 -1
- package/src/core/scope/scope.spec.js +12 -9
- package/src/core/timeout/timeout.spec.js +11 -8
- package/src/directive/attrs/attrs.spec.js +6 -5
- package/src/directive/attrs/boolean.spec.js +3 -3
- package/src/directive/attrs/element-style.spec.js +5 -4
- package/src/directive/attrs/src.spec.js +9 -7
- package/src/directive/bind/bind.spec.js +12 -9
- package/src/directive/bind/bing-html.spec.js +3 -3
- package/src/directive/change/change.spec.js +3 -3
- package/src/directive/class/class.spec.js +3 -3
- package/src/directive/cloak/cloak.spec.js +3 -3
- package/src/directive/controller/controller.spec.js +3 -4
- package/src/directive/events/click.spec.js +4 -4
- package/src/directive/events/event.spec.js +16 -13
- package/src/directive/form/form.spec.js +12 -10
- package/src/directive/if/if.spec.js +2 -3
- package/src/directive/include/include.spec.js +12 -11
- package/src/directive/init/init.spec.js +3 -4
- package/src/directive/input/input.spec.js +11 -9
- package/src/directive/list/list.spec.js +4 -4
- package/src/directive/model/model.spec.js +12 -12
- package/src/directive/model-options/model-options.spec.js +12 -10
- package/src/directive/non-bindable/non-bindable.spec.js +12 -9
- package/src/directive/options/options.spec.js +11 -8
- package/src/directive/ref/href.spec.js +12 -9
- package/src/directive/ref/ref.spec.js +11 -8
- package/src/directive/repeat/repeat.spec.js +12 -11
- package/src/directive/script/script.spec.js +5 -4
- package/src/directive/select/select.spec.js +11 -8
- package/src/directive/show-hide/show-hide.spec.js +5 -4
- package/src/directive/style/style.spec.js +10 -7
- package/src/directive/switch/switch.spec.js +3 -3
- package/src/directive/validators/validators.spec.js +13 -10
- package/src/exts/aria/aria.js +2 -2
- package/src/exts/aria/aria.spec.js +3 -3
- package/src/exts/messages/messages.js +2 -2
- package/src/exts/messages/messages.spec.js +3 -3
- package/src/filters/filter.spec.js +5 -4
- package/src/filters/filters.spec.js +5 -4
- package/src/filters/limit-to.spec.js +5 -4
- package/src/filters/order-by.spec.js +8 -6
- package/src/index.js +2 -8
- package/src/loader.js +107 -539
- package/src/loader.md +142 -0
- package/src/loader.spec.js +8 -27
- package/src/public.js +113 -107
- package/src/public.spec.js +3 -5
- package/src/router/directives/state-directives.spec.js +0 -3
- package/src/router/directives/view-directive.spec.js +0 -6
- package/src/router/index.js +2 -2
- package/src/router/services.spec.js +0 -2
- package/src/router/state/state.spec.js +2 -4
- package/src/router/state-filter.spec.js +0 -2
- package/src/router/template-factory.spec.js +0 -2
- package/src/router/url/url-service.spec.js +0 -2
- package/src/router/view/view.spec.js +1 -2
- package/src/router/view-hook.spec.js +0 -2
- package/src/router/view-scroll.spec.js +0 -3
- package/src/services/http/http.spec.js +3 -3
- package/src/services/http/template-request.spec.js +4 -4
- package/src/services/http-backend/http-backend.spec.js +4 -3
- package/src/shared/jqlite/jqlite.js +0 -2
- package/src/shared/jqlite/jqlite.spec.js +4 -5
- package/src/shared/test-utils.js +1 -1
- package/src/shared/utils.js +10 -1
- package/src/src.html +0 -1
- package/types/animations/module.d.ts +1 -1
- package/types/core/di/injector.d.ts +12 -0
- package/types/core/di/ng-module.d.ts +79 -0
- package/types/exts/aria/aria.d.ts +1 -1
- package/types/exts/messages/messages.d.ts +1 -1
- package/types/index.d.ts +0 -3
- package/types/loader.d.ts +53 -179
- package/types/public.d.ts +6 -1
- package/types/router/index.d.ts +1 -1
- package/types/shared/test-utils.d.ts +3 -2
- package/types/shared/utils.d.ts +7 -1
- package/types/injector.d.ts +0 -12
- /package/src/{injector.md → core/di/injector.md} +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"description": "A modern, optimized and typesafe version of AngularJS",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.65",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
|
@@ -21,7 +21,6 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
// eslint-disable-next-line no-var
|
|
25
24
|
var jasmineRequire = window.jasmineRequire || require("./jasmine.js");
|
|
26
25
|
|
|
27
26
|
jasmineRequire.html = function (j$) {
|
package/src/angular.spec.js
CHANGED
|
@@ -25,17 +25,14 @@ import {
|
|
|
25
25
|
snakeCase,
|
|
26
26
|
} from "./shared/utils";
|
|
27
27
|
import { dealoc, JQLite, startingTag } from "./shared/jqlite/jqlite";
|
|
28
|
-
import { Angular
|
|
29
|
-
import {
|
|
30
|
-
import { createInjector } from "./injector";
|
|
28
|
+
import { Angular } from "./loader";
|
|
29
|
+
import { createInjector } from "./core/di/injector";
|
|
31
30
|
|
|
32
31
|
describe("angular", () => {
|
|
33
32
|
let element, document, module, injector, $rootScope, $compile;
|
|
34
33
|
|
|
35
34
|
beforeEach(() => {
|
|
36
35
|
window.angular = new Angular();
|
|
37
|
-
publishExternalAPI();
|
|
38
|
-
createInjector();
|
|
39
36
|
module = window.angular.module("defaultModule", ["ng"]);
|
|
40
37
|
injector = createInjector(["ng", "defaultModule"]);
|
|
41
38
|
$rootScope = injector.get("$rootScope");
|
|
@@ -1572,7 +1569,7 @@ describe("angular", () => {
|
|
|
1572
1569
|
});
|
|
1573
1570
|
});
|
|
1574
1571
|
|
|
1575
|
-
describe("
|
|
1572
|
+
describe("angular.init", () => {
|
|
1576
1573
|
let bootstrapSpy;
|
|
1577
1574
|
let element;
|
|
1578
1575
|
|
|
@@ -1594,7 +1591,7 @@ describe("angular", () => {
|
|
|
1594
1591
|
});
|
|
1595
1592
|
|
|
1596
1593
|
it("should do nothing when not found", () => {
|
|
1597
|
-
|
|
1594
|
+
window.angular.init(element);
|
|
1598
1595
|
expect(bootstrapSpy).not.toHaveBeenCalled();
|
|
1599
1596
|
});
|
|
1600
1597
|
|
|
@@ -1602,7 +1599,7 @@ describe("angular", () => {
|
|
|
1602
1599
|
window.angular.module("ABC", []);
|
|
1603
1600
|
const appElement = JQLite('<div ng-app="ABC"></div>')[0];
|
|
1604
1601
|
|
|
1605
|
-
|
|
1602
|
+
window.angular.init(appElement);
|
|
1606
1603
|
expect(bootstrapSpy).toHaveBeenCalled();
|
|
1607
1604
|
});
|
|
1608
1605
|
|
|
@@ -1610,27 +1607,27 @@ describe("angular", () => {
|
|
|
1610
1607
|
window.angular.module("ABC", []);
|
|
1611
1608
|
const appElement = JQLite('<div ng-app="ABC"></div>')[0];
|
|
1612
1609
|
element.querySelector["[ng-app]"] = appElement;
|
|
1613
|
-
|
|
1610
|
+
window.angular.init(element);
|
|
1614
1611
|
expect(bootstrapSpy).toHaveBeenCalled();
|
|
1615
1612
|
});
|
|
1616
1613
|
|
|
1617
1614
|
it("should bootstrap anonymously", () => {
|
|
1618
1615
|
const appElement = JQLite("<div ng-app></div>")[0];
|
|
1619
1616
|
element.querySelector["[ng-app]"] = appElement;
|
|
1620
|
-
|
|
1617
|
+
window.angular.init(element);
|
|
1621
1618
|
expect(bootstrapSpy).toHaveBeenCalled();
|
|
1622
1619
|
});
|
|
1623
1620
|
|
|
1624
1621
|
it("should bootstrap if the annotation is on the root element", () => {
|
|
1625
1622
|
const appElement = JQLite('<div ng-app=""></div>')[0];
|
|
1626
|
-
|
|
1623
|
+
window.angular.init(appElement);
|
|
1627
1624
|
expect(bootstrapSpy).toHaveBeenCalled();
|
|
1628
1625
|
});
|
|
1629
1626
|
|
|
1630
1627
|
it("should complain if app module cannot be found", () => {
|
|
1631
1628
|
const appElement = JQLite('<div ng-app="doesntexist"></div>')[0];
|
|
1632
1629
|
expect(() => {
|
|
1633
|
-
|
|
1630
|
+
window.angular.init(appElement);
|
|
1634
1631
|
}).toThrowError(/modulerr/);
|
|
1635
1632
|
});
|
|
1636
1633
|
|
|
@@ -1656,7 +1653,7 @@ describe("angular", () => {
|
|
|
1656
1653
|
|
|
1657
1654
|
it("should bootstrap in strict mode when ng-strict-di attribute is specified", () => {
|
|
1658
1655
|
const appElement = JQLite('<div ng-app="" ng-strict-di></div>');
|
|
1659
|
-
|
|
1656
|
+
window.angular.init(JQLite("<div></div>").append(appElement[0])[0]);
|
|
1660
1657
|
expect(bootstrapSpy).toHaveBeenCalled();
|
|
1661
1658
|
expect(bootstrapSpy.calls.mostRecent().args[2].strictDi).toBe(true);
|
|
1662
1659
|
|
|
@@ -1868,14 +1865,12 @@ describe("angular", () => {
|
|
|
1868
1865
|
});
|
|
1869
1866
|
|
|
1870
1867
|
describe("bootstrap", () => {
|
|
1871
|
-
let module, injector, $rootScope, $compile;
|
|
1868
|
+
let module, injector, $rootScope, $compile, angular;
|
|
1872
1869
|
|
|
1873
1870
|
beforeEach(() => {
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
createInjector();
|
|
1877
|
-
module = window.angular.module("defaultModule", ["ng"]);
|
|
1878
|
-
injector = createInjector(["ng", "defaultModule"]);
|
|
1871
|
+
angular = new Angular();
|
|
1872
|
+
module = angular.module("defaultModule", ["ng"]);
|
|
1873
|
+
injector = createInjector(["defaultModule"]);
|
|
1879
1874
|
$rootScope = injector.get("$rootScope");
|
|
1880
1875
|
$compile = injector.get("$compile");
|
|
1881
1876
|
});
|
package/src/animations/module.js
CHANGED
|
@@ -9,8 +9,8 @@ import { $$AnimateCssDriverProvider } from "./animate-css-driver";
|
|
|
9
9
|
import { $$AnimateJsProvider } from "./animate-js";
|
|
10
10
|
import { $$AnimateJsDriverProvider } from "./animate-js-driver";
|
|
11
11
|
|
|
12
|
-
export function initAnimateModule() {
|
|
13
|
-
|
|
12
|
+
export function initAnimateModule(angular) {
|
|
13
|
+
angular
|
|
14
14
|
.module("ngAnimate", [])
|
|
15
15
|
.directive("ngAnimateSwap", ngAnimateSwapDirective)
|
|
16
16
|
.directive("ngAnimateChildren", $$AnimateChildrenDirective)
|
package/src/binding.spec.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { JQLite, dealoc } from "./shared/jqlite/jqlite";
|
|
2
|
-
import {
|
|
3
|
-
import { createInjector } from "./injector";
|
|
2
|
+
import { Angular } from "./loader";
|
|
3
|
+
import { createInjector } from "./core/di/injector";
|
|
4
4
|
import { browserTrigger } from "./shared/test-utils";
|
|
5
5
|
|
|
6
6
|
describe("binding", () => {
|
|
7
7
|
let element,
|
|
8
|
+
myModule,
|
|
8
9
|
$injector,
|
|
9
10
|
$rootScope,
|
|
10
11
|
$compile,
|
|
@@ -17,12 +18,14 @@ describe("binding", () => {
|
|
|
17
18
|
|
|
18
19
|
beforeEach(function () {
|
|
19
20
|
errors = [];
|
|
20
|
-
|
|
21
|
+
window.angular = new Angular();
|
|
22
|
+
myModule = window.angular.module("myModule", ["ng"]);
|
|
23
|
+
myModule.decorator("$exceptionHandler", function () {
|
|
21
24
|
return (exception, cause) => {
|
|
22
25
|
errors.push(exception.message);
|
|
23
26
|
};
|
|
24
27
|
});
|
|
25
|
-
$injector = createInjector(["
|
|
28
|
+
$injector = createInjector(["myModule"]);
|
|
26
29
|
$rootScope = $injector.get("$rootScope");
|
|
27
30
|
$compile = $injector.get("$compile");
|
|
28
31
|
$exceptionHandler = $injector.get("$exceptionHandler");
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
|
|
2
|
-
import { publishExternalAPI } from "../../public";
|
|
3
2
|
import { Angular } from "../../loader";
|
|
4
3
|
import { isObject } from "../../shared/utils";
|
|
5
4
|
import { isFunction } from "../../shared/utils";
|
|
6
|
-
import { createInjector } from "
|
|
5
|
+
import { createInjector } from "../di/injector";
|
|
7
6
|
|
|
8
7
|
describe("$animate", () => {
|
|
9
8
|
describe("without animation", () => {
|
|
@@ -18,7 +17,6 @@ describe("$animate", () => {
|
|
|
18
17
|
|
|
19
18
|
beforeEach(() => {
|
|
20
19
|
window.angular = new Angular();
|
|
21
|
-
publishExternalAPI();
|
|
22
20
|
defaultModule = window.angular.module("defaultModule", ["ng"]);
|
|
23
21
|
injector = window.angular.bootstrap(dummy, ["defaultModule"]);
|
|
24
22
|
injector.invoke(
|
|
@@ -268,7 +266,7 @@ describe("$animate", () => {
|
|
|
268
266
|
it("$prop() should operate using a native DOM element", () => {
|
|
269
267
|
const captureSpy = jasmine.createSpy();
|
|
270
268
|
dealoc(dummy);
|
|
271
|
-
|
|
269
|
+
window.angular = new Angular();
|
|
272
270
|
defaultModule = window.angular
|
|
273
271
|
.module("defaultModule", ["ng"])
|
|
274
272
|
.value("$$animateQueue", {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createInjector } from "
|
|
1
|
+
import { Angular } from "../../loader";
|
|
2
|
+
import { createInjector } from "../di/injector";
|
|
3
3
|
|
|
4
4
|
describe("$cacheFactory", () => {
|
|
5
5
|
let $cacheFactory;
|
|
6
6
|
|
|
7
7
|
beforeEach(() => {
|
|
8
|
-
|
|
8
|
+
window.angular = new Angular();
|
|
9
9
|
createInjector(["ng"]).invoke((_$cacheFactory_) => {
|
|
10
10
|
$cacheFactory = _$cacheFactory_;
|
|
11
11
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createInjector } from "
|
|
1
|
+
import { Angular } from "../../loader";
|
|
2
|
+
import { createInjector } from "../di/injector";
|
|
3
3
|
import { dealoc, JQLite, getOrSetCacheData } from "../../shared/jqlite/jqlite";
|
|
4
4
|
import {
|
|
5
5
|
forEach,
|
|
@@ -59,7 +59,7 @@ describe("$compile", () => {
|
|
|
59
59
|
|
|
60
60
|
beforeEach(() => {
|
|
61
61
|
log = [];
|
|
62
|
-
|
|
62
|
+
window.angular = new Angular();
|
|
63
63
|
module = window.angular.module("test1", ["ng"]);
|
|
64
64
|
defaultModule = window.angular.module("defaultModule", ["ng"]);
|
|
65
65
|
myModule = window.angular.module("myModule", ["ng"]);
|
|
@@ -6403,12 +6403,14 @@ describe("$compile", () => {
|
|
|
6403
6403
|
|
|
6404
6404
|
describe("replace and not exactly one root element", () => {
|
|
6405
6405
|
beforeEach(() => {
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6406
|
+
window.angular = new Angular();
|
|
6407
|
+
module = window.angular
|
|
6408
|
+
.module("test1", ["ng"])
|
|
6409
|
+
.decorator("$exceptionHandler", () => {
|
|
6410
|
+
return (exception) => {
|
|
6411
|
+
throw new Error(exception.message);
|
|
6412
|
+
};
|
|
6413
|
+
});
|
|
6412
6414
|
module.directive("template", () => ({
|
|
6413
6415
|
replace: true,
|
|
6414
6416
|
templateUrl: "template.html",
|
|
@@ -6756,61 +6758,66 @@ describe("$compile", () => {
|
|
|
6756
6758
|
|
|
6757
6759
|
beforeEach(() => {
|
|
6758
6760
|
log = [];
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6761
|
+
|
|
6762
|
+
window.angular = new Angular();
|
|
6763
|
+
module = window.angular
|
|
6764
|
+
.module("test1", ["ng"])
|
|
6765
|
+
.decorator("$exceptionHandler", () => {
|
|
6766
|
+
return (exception) => {
|
|
6767
|
+
log.push(exception.message);
|
|
6768
|
+
};
|
|
6769
|
+
});
|
|
6770
|
+
|
|
6765
6771
|
["", "a", "b"].forEach((name) => {
|
|
6766
|
-
module
|
|
6767
|
-
scope
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
+
module
|
|
6773
|
+
.directive(`scope${name.toUpperCase()}`, () => ({
|
|
6774
|
+
scope: true,
|
|
6775
|
+
restrict: "A",
|
|
6776
|
+
compile() {
|
|
6777
|
+
return {
|
|
6778
|
+
pre(scope) {
|
|
6779
|
+
log.push(scope.$id);
|
|
6780
|
+
},
|
|
6781
|
+
};
|
|
6782
|
+
},
|
|
6783
|
+
}))
|
|
6784
|
+
.directive(`iscope${name.toUpperCase()}`, () => ({
|
|
6785
|
+
scope: {},
|
|
6786
|
+
restrict: "A",
|
|
6787
|
+
compile() {
|
|
6788
|
+
return function (scope) {
|
|
6789
|
+
iscope = scope;
|
|
6772
6790
|
log.push(scope.$id);
|
|
6773
|
-
}
|
|
6774
|
-
}
|
|
6775
|
-
}
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
}
|
|
6785
|
-
}
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
}
|
|
6795
|
-
}
|
|
6796
|
-
}));
|
|
6797
|
-
module.directive(`stscope${name.toUpperCase()}`, () => ({
|
|
6798
|
-
scope: true,
|
|
6799
|
-
restrict: "A",
|
|
6800
|
-
template: "<span></span>",
|
|
6801
|
-
compile() {
|
|
6802
|
-
return function (scope, element) {
|
|
6803
|
-
log.push(scope.$id);
|
|
6804
|
-
};
|
|
6805
|
-
},
|
|
6806
|
-
}));
|
|
6791
|
+
};
|
|
6792
|
+
},
|
|
6793
|
+
}))
|
|
6794
|
+
.directive(`tscope${name.toUpperCase()}`, () => ({
|
|
6795
|
+
scope: true,
|
|
6796
|
+
restrict: "A",
|
|
6797
|
+
templateUrl: "tscope.html",
|
|
6798
|
+
compile() {
|
|
6799
|
+
return function (scope) {
|
|
6800
|
+
log.push(scope.$id);
|
|
6801
|
+
};
|
|
6802
|
+
},
|
|
6803
|
+
}))
|
|
6804
|
+
.directive(`stscope${name.toUpperCase()}`, () => ({
|
|
6805
|
+
scope: true,
|
|
6806
|
+
restrict: "A",
|
|
6807
|
+
template: "<span></span>",
|
|
6808
|
+
compile() {
|
|
6809
|
+
return function (scope) {
|
|
6810
|
+
log.push(scope.$id);
|
|
6811
|
+
};
|
|
6812
|
+
},
|
|
6813
|
+
}));
|
|
6807
6814
|
module.directive(`trscope${name.toUpperCase()}`, () => ({
|
|
6808
6815
|
scope: true,
|
|
6809
6816
|
replace: true,
|
|
6810
6817
|
restrict: "A",
|
|
6811
6818
|
templateUrl: "trscope.html",
|
|
6812
6819
|
compile() {
|
|
6813
|
-
return function (scope
|
|
6820
|
+
return function (scope) {
|
|
6814
6821
|
log.push(scope.$id);
|
|
6815
6822
|
};
|
|
6816
6823
|
},
|
|
@@ -6820,7 +6827,7 @@ describe("$compile", () => {
|
|
|
6820
6827
|
restrict: "A",
|
|
6821
6828
|
templateUrl: "tiscope.html",
|
|
6822
6829
|
compile() {
|
|
6823
|
-
return function (scope
|
|
6830
|
+
return function (scope) {
|
|
6824
6831
|
iscope = scope;
|
|
6825
6832
|
log.push(scope.$id);
|
|
6826
6833
|
};
|
|
@@ -6831,7 +6838,7 @@ describe("$compile", () => {
|
|
|
6831
6838
|
restrict: "A",
|
|
6832
6839
|
template: "<span></span>",
|
|
6833
6840
|
compile() {
|
|
6834
|
-
return function (scope
|
|
6841
|
+
return function (scope) {
|
|
6835
6842
|
iscope = scope;
|
|
6836
6843
|
log.push(scope.$id);
|
|
6837
6844
|
};
|
|
@@ -11087,7 +11094,6 @@ describe("$compile", () => {
|
|
|
11087
11094
|
|
|
11088
11095
|
it("should eventually expose isolate scope variables on ES6 class controller with controllerAs when bindToController is true", () => {
|
|
11089
11096
|
var controllerCalled = false;
|
|
11090
|
-
// eslint-disable-next-line no-eval
|
|
11091
11097
|
var Controller = eval(
|
|
11092
11098
|
"(\n" +
|
|
11093
11099
|
"class Foo {\n" +
|
|
@@ -17379,7 +17385,7 @@ describe("$compile", () => {
|
|
|
17379
17385
|
$customAnnotation: "XXX",
|
|
17380
17386
|
});
|
|
17381
17387
|
initInjector("test1");
|
|
17382
|
-
expect(myModule.
|
|
17388
|
+
expect(myModule.invokeQueue.pop().pop()[1]).toEqual(
|
|
17383
17389
|
jasmine.objectContaining({
|
|
17384
17390
|
$canActivate: "canActivate",
|
|
17385
17391
|
$routeConfig: "routeConfig",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createInjector } from "
|
|
1
|
+
import { Angular } from "../../loader";
|
|
2
|
+
import { createInjector } from "../di/injector";
|
|
3
3
|
|
|
4
4
|
describe("$controller", () => {
|
|
5
5
|
let $controllerProvider;
|
|
6
6
|
let $controller;
|
|
7
7
|
|
|
8
8
|
beforeEach(() => {
|
|
9
|
-
|
|
9
|
+
window.angular = new Angular();
|
|
10
10
|
createInjector([
|
|
11
11
|
"ng",
|
|
12
12
|
function (_$controllerProvider_) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createInjector } from "
|
|
1
|
+
import { Angular } from "../loader";
|
|
2
|
+
import { createInjector } from "./di/injector";
|
|
3
3
|
|
|
4
4
|
describe("$$cookieReader", () => {
|
|
5
5
|
let $$cookieReader;
|
|
@@ -27,7 +27,7 @@ describe("$$cookieReader", () => {
|
|
|
27
27
|
deleteAllCookies();
|
|
28
28
|
expect(document.cookie).toEqual("");
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
window.angular = new Angular();
|
|
31
31
|
var injector = createInjector(["ng"]);
|
|
32
32
|
$$cookieReader = injector.get("$$cookieReader");
|
|
33
33
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>AngularTS Test Runner</title>
|
|
6
|
+
|
|
7
|
+
<link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
|
|
8
|
+
<link rel="stylesheet" href="/jasmine/jasmine-5.1.2/jasmine.css" />
|
|
9
|
+
<script src="/jasmine/jasmine-5.1.2/jasmine.js"></script>
|
|
10
|
+
<script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
|
|
11
|
+
<script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
|
|
12
|
+
<script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
|
|
13
|
+
<script type="module" src="/src/core/di/injector.spec.js"></script>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="dummy"></div>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -9,17 +9,16 @@ import {
|
|
|
9
9
|
assertArg,
|
|
10
10
|
valueFn,
|
|
11
11
|
assertNotHasOwnProperty,
|
|
12
|
-
reverseParams,
|
|
13
12
|
isObject,
|
|
14
|
-
|
|
15
|
-
} from "
|
|
13
|
+
assert,
|
|
14
|
+
} from "../../shared/utils";
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const ARROW_ARG = /^([^(]+?)=>/;
|
|
17
|
+
const FN_ARGS = /^[^(]*\(\s*([^)]*)\)/m;
|
|
18
|
+
const FN_ARG_SPLIT = /,/;
|
|
19
|
+
const FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
|
|
20
|
+
const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
|
|
21
|
+
const $injectorMinErr = minErr("$injector");
|
|
23
22
|
|
|
24
23
|
function stringifyFn(fn) {
|
|
25
24
|
return Function.prototype.toString.call(fn);
|
|
@@ -82,18 +81,19 @@ const INSTANTIATING = {};
|
|
|
82
81
|
|
|
83
82
|
/**
|
|
84
83
|
*
|
|
85
|
-
* @param {
|
|
86
|
-
* @param {
|
|
87
|
-
* @returns {import("
|
|
84
|
+
* @param {Array<String|Function>} modulesToLoad
|
|
85
|
+
* @param {boolean} [strictDi]
|
|
86
|
+
* @returns {import("../../types").InjectorService}
|
|
88
87
|
*/
|
|
89
|
-
export function createInjector(modulesToLoad, strictDi) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
strictDi = !!strictDi;
|
|
94
|
-
|
|
88
|
+
export function createInjector(modulesToLoad, strictDi = false) {
|
|
89
|
+
assert(Array.isArray(modulesToLoad), "modules required");
|
|
90
|
+
assert(isBoolean(strictDi));
|
|
91
|
+
/** @type {Array<string>} */
|
|
95
92
|
const path = [];
|
|
96
|
-
|
|
93
|
+
|
|
94
|
+
/** @type {Map<String|Function, boolean>} */
|
|
95
|
+
const loadedModules = new Map(); // Keep track of loaded modules to avoid circular dependencies
|
|
96
|
+
|
|
97
97
|
const providerCache = {
|
|
98
98
|
$provide: {
|
|
99
99
|
provider: supportObject(provider),
|
|
@@ -105,21 +105,22 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
105
105
|
},
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
providerCache.$injector = createInternalInjector(
|
|
109
109
|
providerCache,
|
|
110
|
-
function (
|
|
110
|
+
function (caller) {
|
|
111
111
|
if (isString(caller)) {
|
|
112
112
|
path.push(caller);
|
|
113
113
|
}
|
|
114
114
|
throw $injectorMinErr("unpr", "Unknown provider: {0}", path.join(" <- "));
|
|
115
115
|
},
|
|
116
|
-
)
|
|
116
|
+
);
|
|
117
|
+
|
|
117
118
|
const instanceCache = {};
|
|
118
119
|
|
|
119
120
|
let protoInstanceInjector = createInternalInjector(
|
|
120
121
|
instanceCache,
|
|
121
122
|
(serviceName, caller) => {
|
|
122
|
-
const provider =
|
|
123
|
+
const provider = providerCache.$injector.get(
|
|
123
124
|
serviceName + providerSuffix,
|
|
124
125
|
caller,
|
|
125
126
|
);
|
|
@@ -136,8 +137,9 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
136
137
|
$get: valueFn(protoInstanceInjector),
|
|
137
138
|
};
|
|
138
139
|
let instanceInjector = protoInstanceInjector;
|
|
139
|
-
instanceInjector.modules =
|
|
140
|
-
|
|
140
|
+
instanceInjector.modules = providerCache.$injector.modules =
|
|
141
|
+
Object.create(null);
|
|
142
|
+
const runBlocks = loadModules(modulesToLoad);
|
|
141
143
|
instanceInjector = protoInstanceInjector.get("$injector");
|
|
142
144
|
instanceInjector.strictDi = strictDi;
|
|
143
145
|
runBlocks.forEach((fn) => {
|
|
@@ -159,26 +161,28 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
159
161
|
function supportObject(delegate) {
|
|
160
162
|
return function (key, value) {
|
|
161
163
|
if (isObject(key)) {
|
|
162
|
-
forEach(
|
|
164
|
+
Object.entries(key).forEach(([k, v]) => {
|
|
165
|
+
delegate(k, v);
|
|
166
|
+
});
|
|
163
167
|
} else {
|
|
164
168
|
return delegate(key, value);
|
|
165
169
|
}
|
|
166
170
|
};
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
function provider(name,
|
|
173
|
+
function provider(name, provider) {
|
|
170
174
|
assertNotHasOwnProperty(name, "service");
|
|
171
|
-
if (isFunction(
|
|
172
|
-
|
|
175
|
+
if (isFunction(provider) || Array.isArray(provider)) {
|
|
176
|
+
provider = providerCache.$injector.instantiate(provider);
|
|
173
177
|
}
|
|
174
|
-
if (!
|
|
178
|
+
if (!provider.$get) {
|
|
175
179
|
throw $injectorMinErr(
|
|
176
180
|
"pget",
|
|
177
181
|
"Provider '{0}' must define $get factory method.",
|
|
178
182
|
name,
|
|
179
183
|
);
|
|
180
184
|
}
|
|
181
|
-
return (providerCache[name + providerSuffix] =
|
|
185
|
+
return (providerCache[name + providerSuffix] = provider);
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
function enforceReturnValue(name, factory) {
|
|
@@ -221,7 +225,9 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
function decorator(serviceName, decorFn) {
|
|
224
|
-
const origProvider =
|
|
228
|
+
const origProvider = providerCache.$injector.get(
|
|
229
|
+
serviceName + providerSuffix,
|
|
230
|
+
);
|
|
225
231
|
const orig$get = origProvider.$get;
|
|
226
232
|
|
|
227
233
|
origProvider.$get = function () {
|
|
@@ -235,6 +241,11 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
235
241
|
////////////////////////////////////
|
|
236
242
|
// Module Loading
|
|
237
243
|
////////////////////////////////////
|
|
244
|
+
/**
|
|
245
|
+
*
|
|
246
|
+
* @param {Array<String|Function>} modulesToLoad
|
|
247
|
+
* @returns
|
|
248
|
+
*/
|
|
238
249
|
function loadModules(modulesToLoad) {
|
|
239
250
|
assertArg(
|
|
240
251
|
isUndefined(modulesToLoad) || Array.isArray(modulesToLoad),
|
|
@@ -242,34 +253,36 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
242
253
|
"not an array",
|
|
243
254
|
);
|
|
244
255
|
let runBlocks = [];
|
|
245
|
-
|
|
246
|
-
forEach(
|
|
256
|
+
|
|
257
|
+
modulesToLoad.forEach((module) => {
|
|
247
258
|
if (loadedModules.get(module)) return;
|
|
248
259
|
loadedModules.set(module, true);
|
|
249
260
|
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
* @param {Array<Array<any>>} queue
|
|
264
|
+
*/
|
|
250
265
|
function runInvokeQueue(queue) {
|
|
251
266
|
queue.forEach((invokeArgs) => {
|
|
252
|
-
const provider =
|
|
267
|
+
const provider = providerCache.$injector.get(invokeArgs[0]);
|
|
253
268
|
provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
|
|
254
269
|
});
|
|
255
270
|
}
|
|
256
271
|
|
|
257
272
|
try {
|
|
258
273
|
if (isString(module)) {
|
|
259
|
-
|
|
274
|
+
/** @type {import('./ng-module').NgModule} */
|
|
275
|
+
let moduleFn = window["angular"].module(module);
|
|
260
276
|
instanceInjector.modules[module] = moduleFn;
|
|
261
277
|
runBlocks = runBlocks
|
|
262
278
|
.concat(loadModules(moduleFn.requires))
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
runInvokeQueue(moduleFn._invokeQueue);
|
|
267
|
-
// @ts-ignore
|
|
268
|
-
runInvokeQueue(moduleFn._configBlocks);
|
|
279
|
+
.concat(moduleFn.runBlocks);
|
|
280
|
+
runInvokeQueue(moduleFn.invokeQueue);
|
|
281
|
+
runInvokeQueue(moduleFn.configBlocks);
|
|
269
282
|
} else if (isFunction(module)) {
|
|
270
|
-
runBlocks.push(
|
|
283
|
+
runBlocks.push(providerCache.$injector.invoke(module));
|
|
271
284
|
} else if (Array.isArray(module)) {
|
|
272
|
-
runBlocks.push(
|
|
285
|
+
runBlocks.push(providerCache.$injector.invoke(module));
|
|
273
286
|
} else {
|
|
274
287
|
assertArgFn(module, "module");
|
|
275
288
|
}
|
|
@@ -283,7 +296,7 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
283
296
|
// So if stack doesn't contain message, we create a new string that contains both.
|
|
284
297
|
// Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
|
|
285
298
|
|
|
286
|
-
e = `${e.message}\n${e.stack}`;
|
|
299
|
+
e.message = `${e.message}\n${e.stack}`;
|
|
287
300
|
}
|
|
288
301
|
throw $injectorMinErr(
|
|
289
302
|
"modulerr",
|