@angular-wave/angular.ts 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.umd.js +10 -0
- package/index.html +74 -3
- package/package.json +1 -1
- package/src/angular.spec.js +0 -5
- package/src/animations/animate-css.js +5 -13
- package/src/animations/animate-queue.js +22 -21
- package/src/animations/animate-runner.js +4 -8
- package/src/animations/animate.md +1 -1
- package/src/animations/animate.spec.js +0 -21
- package/src/animations/animation.js +1 -1
- package/src/binding.spec.js +0 -1
- package/src/core/cache/cache.js +2 -29
- package/src/core/compile/compile.js +26 -27
- package/src/core/compile/compile.spec.js +17 -266
- package/src/core/compile/compile.test.js +1 -1
- package/src/core/controller/controller.js +2 -0
- package/src/core/di/injector.md +1 -1
- package/src/core/di/injector.spec.js +0 -2
- package/src/core/di/internal-injector.js +2 -1
- package/src/core/interpolate/interpolate.js +16 -3
- package/src/core/interpolate/interpolate.spec.js +70 -16
- package/src/core/interval/interval.test.js +1 -1
- package/src/core/location/location.js +0 -2
- package/src/core/location/location.spec.js +27 -27
- package/src/core/{scope/scope.html → model/model.html} +1 -1
- package/src/core/model/model.js +944 -0
- package/src/core/model/model.spec.js +3012 -0
- package/src/core/on.spec.js +0 -7
- package/src/core/parse/interpreter.js +10 -7
- package/src/core/parse/parse.js +26 -5
- package/src/core/parse/parse.spec.js +95 -91
- package/src/core/prop.spec.js +4 -60
- package/src/core/sce/sce.spec.js +0 -8
- package/src/core/scope/scope.js +61 -30
- package/src/core/scope/scope.spec.js +25 -1960
- package/src/directive/aria/aria.js +3 -6
- package/src/directive/aria/aria.spec.js +0 -87
- package/src/directive/attrs/attrs.spec.js +0 -5
- package/src/directive/attrs/boolean.spec.js +0 -15
- package/src/directive/attrs/element-style.spec.js +0 -8
- package/src/directive/attrs/src.spec.js +0 -7
- package/src/directive/bind/bind.spec.js +0 -33
- package/src/directive/bind/bing-html.spec.js +0 -3
- package/src/{core/q/q.html → directive/channel/channel.html} +1 -1
- package/src/directive/channel/channel.js +29 -0
- package/src/directive/channel/channel.spec.js +52 -0
- package/src/directive/{list/list.test.js → channel/channel.test.js} +2 -4
- package/src/directive/class/class.js +3 -3
- package/src/directive/class/class.spec.js +9 -75
- package/src/directive/controller/controller.spec.js +0 -13
- package/src/directive/events/click.spec.js +0 -3
- package/src/directive/events/event.spec.js +0 -6
- package/src/directive/form/form.js +2 -3
- package/src/directive/form/form.spec.js +0 -65
- package/src/directive/if/if.spec.js +0 -4
- package/src/directive/include/include.spec.js +8 -59
- package/src/directive/init/init.js +6 -2
- package/src/directive/init/init.spec.js +0 -2
- package/src/directive/input/input.spec.js +0 -136
- package/src/directive/messages/messages.spec.js +4 -35
- package/src/directive/model/model.js +18 -25
- package/src/directive/model/model.spec.js +2 -49
- package/src/directive/model-options/model-options.spec.js +0 -6
- package/src/directive/non-bindable/non-bindable.spec.js +0 -1
- package/src/directive/observe/observe.js +0 -1
- package/src/directive/observe/observe.spec.js +0 -1
- package/src/directive/options/options.spec.js +0 -34
- package/src/directive/ref/href.spec.js +0 -15
- package/src/directive/repeat/repeat.spec.js +8 -135
- package/src/directive/script/script.spec.js +0 -2
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +0 -96
- package/src/directive/show-hide/show-hide.js +2 -2
- package/src/directive/show-hide/show-hide.spec.js +8 -19
- package/src/directive/style/style.spec.js +0 -7
- package/src/directive/switch/switch.spec.js +5 -5
- package/src/directive/validators/validators.spec.js +0 -1
- package/src/loader.js +0 -1
- package/src/public.js +75 -80
- package/src/router/common/coreservices.js +0 -2
- package/src/router/directives/state-directives.js +6 -14
- package/src/router/directives/state-directives.spec.js +0 -83
- package/src/router/directives/view-directive.js +4 -13
- package/src/router/directives/view-directive.spec.js +25 -71
- package/src/router/hooks/lazy-load.js +2 -2
- package/src/router/hooks/views.js +3 -5
- package/src/router/resolve/resolvable.js +3 -6
- package/src/router/resolve/resolve-context.js +2 -2
- package/src/router/state/state-service.js +4 -4
- package/src/router/state/state.spec.js +2 -5
- package/src/router/state/views.js +7 -10
- package/src/router/template-factory.js +3 -6
- package/src/router/template-factory.spec.js +0 -4
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/transition/transition.js +1 -1
- package/src/router/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +4 -6
- package/src/services/http/http.js +6 -9
- package/src/services/http/http.spec.js +30 -31
- package/src/services/http/template-request.spec.js +0 -10
- package/src/services/http-backend/http-backend.spec.js +3 -3
- package/src/services/template-request.js +2 -4
- package/src/shared/common.js +1 -2
- package/src/shared/jqlite/jqlite.js +0 -3
- package/types/core/cache/cache.d.ts +1 -1
- package/types/core/model/model.d.ts +204 -0
- package/types/core/parse/parse.d.ts +26 -0
- package/types/core/scope/scope.d.ts +22 -21
- package/types/directive/channel/channel.d.ts +11 -0
- package/src/core/interval/interval-factory.js +0 -50
- package/src/core/interval/interval.html +0 -18
- package/src/core/interval/interval.js +0 -77
- package/src/core/interval/interval.md +0 -123
- package/src/core/interval/interval.spec.js +0 -280
- package/src/core/q/q.js +0 -472
- package/src/core/q/q.md +0 -211
- package/src/core/q/q.spec.js +0 -2748
- package/src/core/q/q.test.js +0 -12
- package/src/core/scope/scope.test.js +0 -12
- package/src/core/timeout/timeout.html +0 -18
- package/src/core/timeout/timeout.js +0 -109
- package/src/core/timeout/timeout.spec.js +0 -354
- package/src/core/timeout/timout.test.js +0 -12
- package/src/directive/list/list.html +0 -18
- package/src/directive/list/list.js +0 -46
- package/src/directive/list/list.md +0 -22
- package/src/directive/list/list.spec.js +0 -172
- package/types/directive/list/list.d.ts +0 -4
|
@@ -20,8 +20,6 @@ describe("ngView", () => {
|
|
|
20
20
|
app,
|
|
21
21
|
$injector,
|
|
22
22
|
$state,
|
|
23
|
-
$q,
|
|
24
|
-
$timeout,
|
|
25
23
|
$ngViewScroll;
|
|
26
24
|
|
|
27
25
|
const aState = {
|
|
@@ -167,11 +165,10 @@ describe("ngView", () => {
|
|
|
167
165
|
]);
|
|
168
166
|
|
|
169
167
|
$injector.invoke(
|
|
170
|
-
(_$state_, _$
|
|
168
|
+
(_$state_, _$timeout_, $rootScope, _$compile_, _$ngViewScroll_) => {
|
|
171
169
|
scope = $rootScope.$new();
|
|
172
170
|
$compile = _$compile_;
|
|
173
171
|
$state = _$state_;
|
|
174
|
-
$q = _$q_;
|
|
175
172
|
$timeout = _$timeout_;
|
|
176
173
|
elem = JQLite("<div>");
|
|
177
174
|
$ngViewScroll = _$ngViewScroll_;
|
|
@@ -390,7 +387,7 @@ describe("ngView", () => {
|
|
|
390
387
|
name: "resolve",
|
|
391
388
|
resolve: {
|
|
392
389
|
user: function () {
|
|
393
|
-
return
|
|
390
|
+
return setTimeout(() => {
|
|
394
391
|
return "joeschmoe";
|
|
395
392
|
}, 100);
|
|
396
393
|
},
|
|
@@ -528,22 +525,16 @@ describe("ngView", () => {
|
|
|
528
525
|
|
|
529
526
|
// Turn on the div that holds the ng-view
|
|
530
527
|
scope.someBoolean = true;
|
|
531
|
-
scope.$digest();
|
|
532
|
-
|
|
533
528
|
// Verify that the ng-view is there and it has the correct content
|
|
534
529
|
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
535
530
|
|
|
536
531
|
// Turn off the ng-view
|
|
537
532
|
scope.someBoolean = false;
|
|
538
|
-
scope.$digest();
|
|
539
|
-
|
|
540
533
|
// Verify there is no ng-view in the DOM
|
|
541
534
|
expect(elem.find("ng-view").length).toBe(0);
|
|
542
535
|
|
|
543
536
|
// Turn on the div that holds the ng-view once again
|
|
544
537
|
scope.someBoolean = true;
|
|
545
|
-
scope.$digest();
|
|
546
|
-
|
|
547
538
|
// Verify that the ng-view is there and it has the correct content
|
|
548
539
|
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
549
540
|
});
|
|
@@ -561,13 +552,9 @@ describe("ngView", () => {
|
|
|
561
552
|
expect(classes(elem.find("ng-view"))).not.toContain("someClass");
|
|
562
553
|
|
|
563
554
|
scope.showClass = true;
|
|
564
|
-
scope.$digest();
|
|
565
|
-
|
|
566
555
|
expect(classes(elem.find("ng-view"))).toContain("someClass");
|
|
567
556
|
|
|
568
557
|
scope.showClass = false;
|
|
569
|
-
scope.$digest();
|
|
570
|
-
|
|
571
558
|
expect(classes(elem.find("ng-view"))).not.toContain("someClass");
|
|
572
559
|
});
|
|
573
560
|
|
|
@@ -584,23 +571,17 @@ describe("ngView", () => {
|
|
|
584
571
|
|
|
585
572
|
// Lets add 3
|
|
586
573
|
scope.views = ["view1", "view2", "view3"];
|
|
587
|
-
scope.$digest();
|
|
588
|
-
|
|
589
574
|
// Should be 3 ng-views in the DOM
|
|
590
575
|
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
591
576
|
|
|
592
577
|
// Lets add one more - yay two-way binding
|
|
593
578
|
scope.views.push("view4");
|
|
594
|
-
scope.$digest();
|
|
595
|
-
|
|
596
579
|
// Should have 4 ng-views
|
|
597
580
|
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
598
581
|
|
|
599
582
|
// Lets remove 2 ng-views from the DOM
|
|
600
583
|
scope.views.pop();
|
|
601
584
|
scope.views.pop();
|
|
602
|
-
scope.$digest();
|
|
603
|
-
|
|
604
585
|
// Should have 2 ng-views
|
|
605
586
|
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
606
587
|
});
|
|
@@ -619,8 +600,6 @@ describe("ngView", () => {
|
|
|
619
600
|
|
|
620
601
|
scope.views = ["view1", "view2"];
|
|
621
602
|
|
|
622
|
-
scope.$digest();
|
|
623
|
-
|
|
624
603
|
let ngViews = elem.find("ng-view");
|
|
625
604
|
|
|
626
605
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -628,8 +607,6 @@ describe("ngView", () => {
|
|
|
628
607
|
expect(ngViews.eq(2).length).toBe(0);
|
|
629
608
|
|
|
630
609
|
scope.views.push("view3");
|
|
631
|
-
scope.$digest();
|
|
632
|
-
|
|
633
610
|
ngViews = elem.find("ng-view");
|
|
634
611
|
|
|
635
612
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -653,8 +630,6 @@ describe("ngView", () => {
|
|
|
653
630
|
|
|
654
631
|
scope.views = ["view1", "view2"];
|
|
655
632
|
|
|
656
|
-
scope.$digest();
|
|
657
|
-
|
|
658
633
|
let ngViews = elem.find("ng-view");
|
|
659
634
|
|
|
660
635
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -662,8 +637,6 @@ describe("ngView", () => {
|
|
|
662
637
|
expect(ngViews.eq(2).length).toBe(0);
|
|
663
638
|
|
|
664
639
|
scope.views.push("view3");
|
|
665
|
-
scope.$digest();
|
|
666
|
-
|
|
667
640
|
ngViews = elem.find("ng-view");
|
|
668
641
|
|
|
669
642
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -732,14 +705,14 @@ describe("ngView", () => {
|
|
|
732
705
|
// $animate.queue.shift();
|
|
733
706
|
|
|
734
707
|
// scope.classOn = true;
|
|
735
|
-
//
|
|
708
|
+
// ;
|
|
736
709
|
|
|
737
710
|
// animation = $animate.queue.shift();
|
|
738
711
|
// expect(animation.event).toBe("addClass");
|
|
739
712
|
// expect(animation.element.text()).toBe(content);
|
|
740
713
|
|
|
741
714
|
// scope.classOn = false;
|
|
742
|
-
//
|
|
715
|
+
// ;
|
|
743
716
|
|
|
744
717
|
// animation = $animate.queue.shift();
|
|
745
718
|
// expect(animation.event).toBe("removeClass");
|
|
@@ -763,7 +736,7 @@ describe("ngView", () => {
|
|
|
763
736
|
// expect($animate.queue.length).toBe(0);
|
|
764
737
|
|
|
765
738
|
// scope.shouldShow = true;
|
|
766
|
-
//
|
|
739
|
+
// ;
|
|
767
740
|
|
|
768
741
|
// // $ViewDirective enter animation - Basically it's just the <!-- ngView --> comment
|
|
769
742
|
// animation = $animate.queue.shift();
|
|
@@ -776,7 +749,7 @@ describe("ngView", () => {
|
|
|
776
749
|
// expect(animation.element.text()).toBe(content);
|
|
777
750
|
|
|
778
751
|
// scope.shouldShow = false;
|
|
779
|
-
//
|
|
752
|
+
// ;
|
|
780
753
|
|
|
781
754
|
// // ngView leave animation
|
|
782
755
|
// animation = $animate.queue.shift();
|
|
@@ -1048,8 +1021,6 @@ describe("ngView controllers or onEnter handlers", () => {
|
|
|
1048
1021
|
it("should not go into an infinite loop when controller uses $state.go", async () => {
|
|
1049
1022
|
el = JQLite("<div><ng-view></ng-view></div>");
|
|
1050
1023
|
template = $compile(el)($rootScope);
|
|
1051
|
-
$rootScope.$digest();
|
|
1052
|
-
|
|
1053
1024
|
await $state.transitionTo("aside");
|
|
1054
1025
|
await wait(100);
|
|
1055
1026
|
expect(template[0].querySelector(".aside")).toBeDefined();
|
|
@@ -1368,8 +1339,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1368
1339
|
});
|
|
1369
1340
|
|
|
1370
1341
|
const $state = svcs.$state,
|
|
1371
|
-
$httpBackend = svcs.$httpBackend
|
|
1372
|
-
$q = svcs.$q;
|
|
1342
|
+
$httpBackend = svcs.$httpBackend;
|
|
1373
1343
|
|
|
1374
1344
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1375
1345
|
$state.transitionTo("route2cmp");
|
|
@@ -1415,8 +1385,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1415
1385
|
});
|
|
1416
1386
|
|
|
1417
1387
|
const $state = svcs.$state,
|
|
1418
|
-
$httpBackend = svcs.$httpBackend
|
|
1419
|
-
$q = svcs.$q;
|
|
1388
|
+
$httpBackend = svcs.$httpBackend;
|
|
1420
1389
|
|
|
1421
1390
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1422
1391
|
$state.transitionTo("route2cmp");
|
|
@@ -1440,8 +1409,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1440
1409
|
});
|
|
1441
1410
|
|
|
1442
1411
|
const $state = svcs.$state,
|
|
1443
|
-
$httpBackend = svcs.$httpBackend
|
|
1444
|
-
$q = svcs.$q;
|
|
1412
|
+
$httpBackend = svcs.$httpBackend;
|
|
1445
1413
|
|
|
1446
1414
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1447
1415
|
$state.transitionTo("route2cmp");
|
|
@@ -1462,8 +1430,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1462
1430
|
});
|
|
1463
1431
|
|
|
1464
1432
|
const $state = svcs.$state,
|
|
1465
|
-
$httpBackend = svcs.$httpBackend
|
|
1466
|
-
$q = svcs.$q;
|
|
1433
|
+
$httpBackend = svcs.$httpBackend;
|
|
1467
1434
|
|
|
1468
1435
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1469
1436
|
$state.transitionTo("route2cmp");
|
|
@@ -1491,8 +1458,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1491
1458
|
});
|
|
1492
1459
|
|
|
1493
1460
|
const $state = svcs.$state,
|
|
1494
|
-
$httpBackend = svcs.$httpBackend
|
|
1495
|
-
$q = svcs.$q;
|
|
1461
|
+
$httpBackend = svcs.$httpBackend;
|
|
1496
1462
|
|
|
1497
1463
|
$state.transitionTo("bindingtypes");
|
|
1498
1464
|
await wait(100);
|
|
@@ -1547,8 +1513,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1547
1513
|
component: "dataComponent",
|
|
1548
1514
|
});
|
|
1549
1515
|
|
|
1550
|
-
const $state = svcs.$state
|
|
1551
|
-
$q = svcs.$q;
|
|
1516
|
+
const $state = svcs.$state;
|
|
1552
1517
|
$state.transitionTo("data");
|
|
1553
1518
|
await wait(100);
|
|
1554
1519
|
|
|
@@ -1563,8 +1528,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1563
1528
|
resolve: { dataUser: () => "user" },
|
|
1564
1529
|
});
|
|
1565
1530
|
|
|
1566
|
-
const $state = svcs.$state
|
|
1567
|
-
$q = svcs.$q;
|
|
1531
|
+
const $state = svcs.$state;
|
|
1568
1532
|
$state.transitionTo("data");
|
|
1569
1533
|
await wait(100);
|
|
1570
1534
|
|
|
@@ -1573,8 +1537,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1573
1537
|
|
|
1574
1538
|
// Test for #3239
|
|
1575
1539
|
it("should pass any bindings (wired from a parent component template via the ng-view) through to the child", async () => {
|
|
1576
|
-
const $state = svcs.$state
|
|
1577
|
-
$q = svcs.$q;
|
|
1540
|
+
const $state = svcs.$state;
|
|
1578
1541
|
|
|
1579
1542
|
$stateProvider.state({
|
|
1580
1543
|
name: "parent",
|
|
@@ -1598,8 +1561,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1598
1561
|
|
|
1599
1562
|
// Test for #3239
|
|
1600
1563
|
it("should prefer ng-view bindings over resolve data", async () => {
|
|
1601
|
-
const $state = svcs.$state
|
|
1602
|
-
$q = svcs.$q;
|
|
1564
|
+
const $state = svcs.$state;
|
|
1603
1565
|
|
|
1604
1566
|
$stateProvider.state({
|
|
1605
1567
|
name: "parent",
|
|
@@ -1628,8 +1590,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1628
1590
|
|
|
1629
1591
|
// Test for #3239
|
|
1630
1592
|
it("should prefer ng-view bindings over resolve data unless a bindings exists", async () => {
|
|
1631
|
-
const $state = svcs.$state
|
|
1632
|
-
$q = svcs.$q;
|
|
1593
|
+
const $state = svcs.$state;
|
|
1633
1594
|
|
|
1634
1595
|
$stateProvider.state({
|
|
1635
1596
|
name: "parent",
|
|
@@ -1659,8 +1620,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1659
1620
|
|
|
1660
1621
|
// Test for #3239
|
|
1661
1622
|
it("should pass & bindings (wired from a parent component via the ng-view) through to the child", async () => {
|
|
1662
|
-
const $state = svcs.$state
|
|
1663
|
-
$q = svcs.$q;
|
|
1623
|
+
const $state = svcs.$state;
|
|
1664
1624
|
$rootScope.log = [];
|
|
1665
1625
|
|
|
1666
1626
|
$stateProvider.state({
|
|
@@ -1693,9 +1653,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1693
1653
|
|
|
1694
1654
|
// Test for #3111
|
|
1695
1655
|
it("should bind & bindings to a resolve that returns a function", async () => {
|
|
1696
|
-
const $state = svcs.$state
|
|
1697
|
-
|
|
1698
|
-
log = [];
|
|
1656
|
+
const $state = svcs.$state;
|
|
1657
|
+
log = [];
|
|
1699
1658
|
|
|
1700
1659
|
$stateProvider.state({
|
|
1701
1660
|
name: "resolve",
|
|
@@ -1717,9 +1676,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1717
1676
|
|
|
1718
1677
|
// Test for #3111
|
|
1719
1678
|
it("should bind & bindings to a resolve that returns an array-style function", async () => {
|
|
1720
|
-
const $state = svcs.$state
|
|
1721
|
-
|
|
1722
|
-
log = [];
|
|
1679
|
+
const $state = svcs.$state;
|
|
1680
|
+
log = [];
|
|
1723
1681
|
|
|
1724
1682
|
$stateProvider.state({
|
|
1725
1683
|
name: "resolve",
|
|
@@ -1812,8 +1770,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1812
1770
|
};
|
|
1813
1771
|
$stateProvider.state(stateDef);
|
|
1814
1772
|
const $state = svcs.$state,
|
|
1815
|
-
$httpBackend = svcs.$httpBackend
|
|
1816
|
-
$q = svcs.$q;
|
|
1773
|
+
$httpBackend = svcs.$httpBackend;
|
|
1817
1774
|
|
|
1818
1775
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1819
1776
|
$state.transitionTo("route2cmp");
|
|
@@ -1884,8 +1841,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1884
1841
|
});
|
|
1885
1842
|
|
|
1886
1843
|
const $state = svcs.$state,
|
|
1887
|
-
$httpBackend = svcs.$httpBackend
|
|
1888
|
-
$q = svcs.$q;
|
|
1844
|
+
$httpBackend = svcs.$httpBackend;
|
|
1889
1845
|
|
|
1890
1846
|
$templateCache.set(
|
|
1891
1847
|
"/comp_tpl.html",
|
|
@@ -1914,8 +1870,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1914
1870
|
],
|
|
1915
1871
|
});
|
|
1916
1872
|
|
|
1917
|
-
const $state = svcs.$state
|
|
1918
|
-
$q = svcs.$q;
|
|
1873
|
+
const $state = svcs.$state;
|
|
1919
1874
|
|
|
1920
1875
|
$state.transitionTo("ng12-dynamic-directive", {
|
|
1921
1876
|
type: "ng12DynamicDirective",
|
|
@@ -1997,8 +1952,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1997
1952
|
});
|
|
1998
1953
|
|
|
1999
1954
|
it("should work with componentProvider", async () => {
|
|
2000
|
-
const $state = svcs.$state
|
|
2001
|
-
$q = svcs.$q;
|
|
1955
|
+
const $state = svcs.$state;
|
|
2002
1956
|
$state.go("dynamic2", { param: "abc" });
|
|
2003
1957
|
await wait(100);
|
|
2004
1958
|
$state.go("dynamic2", { param: "def" });
|
|
@@ -61,7 +61,7 @@ export function registerLazyLoadHook(
|
|
|
61
61
|
.entering()
|
|
62
62
|
.filter((state) => !!state.$$state().lazyLoad)
|
|
63
63
|
.map((state) => lazyLoadState(transition, state, stateRegistry));
|
|
64
|
-
return
|
|
64
|
+
return Promise.all(promises).then(retryTransition);
|
|
65
65
|
},
|
|
66
66
|
);
|
|
67
67
|
}
|
|
@@ -86,7 +86,7 @@ export function lazyLoadState(transition, state, stateRegistry) {
|
|
|
86
86
|
};
|
|
87
87
|
const error = (err) => {
|
|
88
88
|
delete lazyLoadFn["_promise"];
|
|
89
|
-
return
|
|
89
|
+
return Promise.reject(err);
|
|
90
90
|
};
|
|
91
91
|
promise = lazyLoadFn["_promise"] = services.$q
|
|
92
92
|
.resolve(lazyLoadFn(transition, state))
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { services } from "../common/coreservices";
|
|
2
1
|
/**
|
|
3
2
|
* A [[TransitionHookFn]] which waits for the views to load
|
|
4
3
|
*
|
|
@@ -8,12 +7,11 @@ import { services } from "../common/coreservices";
|
|
|
8
7
|
* In angular 1, this includes loading the templates.
|
|
9
8
|
*/
|
|
10
9
|
const loadEnteringViews = (transition) => {
|
|
11
|
-
const $q = services.$q;
|
|
12
10
|
const enteringViews = transition.views("entering");
|
|
13
11
|
if (!enteringViews.length) return;
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
return Promise.all(
|
|
13
|
+
enteringViews.map((view) => Promise.resolve(view.load())),
|
|
14
|
+
).then(() => {});
|
|
17
15
|
};
|
|
18
16
|
export const registerLoadEnteringViews = (transitionService) =>
|
|
19
17
|
transitionService.onFinish({}, loadEnteringViews);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assert, isFunction, isObject } from "../../shared/utils";
|
|
2
|
-
import { services } from "../common/coreservices";
|
|
3
2
|
import { trace } from "../common/trace";
|
|
4
3
|
import { stringify } from "../../shared/strings";
|
|
5
4
|
import { isNullOrUndefined } from "../../shared/predicates";
|
|
@@ -34,7 +33,7 @@ export class Resolvable {
|
|
|
34
33
|
this.deps = deps || [];
|
|
35
34
|
this.data = data;
|
|
36
35
|
this.resolved = data !== undefined;
|
|
37
|
-
this.promise = this.resolved ?
|
|
36
|
+
this.promise = this.resolved ? Promise.resolve(this.data) : undefined;
|
|
38
37
|
} else if (
|
|
39
38
|
isObject(arg1) &&
|
|
40
39
|
arg1.token &&
|
|
@@ -67,10 +66,9 @@ export class Resolvable {
|
|
|
67
66
|
* and update the Resolvable's state
|
|
68
67
|
*/
|
|
69
68
|
resolve(resolveContext, trans) {
|
|
70
|
-
const $q = services.$q;
|
|
71
69
|
// Gets all dependencies from ResolveContext and wait for them to be resolved
|
|
72
70
|
const getResolvableDependencies = () =>
|
|
73
|
-
|
|
71
|
+
Promise.all(
|
|
74
72
|
resolveContext
|
|
75
73
|
.getDependencies(this)
|
|
76
74
|
.map((resolvable) => resolvable.get(resolveContext, trans)),
|
|
@@ -91,8 +89,7 @@ export class Resolvable {
|
|
|
91
89
|
return this.data;
|
|
92
90
|
};
|
|
93
91
|
// Sets the promise property first, then getsResolvableDependencies in the context of the promise chain. Always waits one tick.
|
|
94
|
-
return (this.promise =
|
|
95
|
-
.resolve()
|
|
92
|
+
return (this.promise = Promise.resolve()
|
|
96
93
|
.then(getResolvableDependencies)
|
|
97
94
|
.then(invokeResolveFn)
|
|
98
95
|
.then(customAsyncPolicy)
|
|
@@ -119,7 +119,7 @@ export class ResolveContext {
|
|
|
119
119
|
*
|
|
120
120
|
* @param {string} when
|
|
121
121
|
* @param trans
|
|
122
|
-
* @returns {
|
|
122
|
+
* @returns {Promise<any>|any}
|
|
123
123
|
*/
|
|
124
124
|
resolvePath(when = "LAZY", trans) {
|
|
125
125
|
// This option determines which 'when' policy Resolvables we are about to fetch.
|
|
@@ -153,7 +153,7 @@ export class ResolveContext {
|
|
|
153
153
|
return acc.concat(wait.map(getResult));
|
|
154
154
|
}, []);
|
|
155
155
|
// Wait for all the "WAIT" resolvables
|
|
156
|
-
return
|
|
156
|
+
return Promise.all(promises);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
injector() {
|
|
@@ -244,7 +244,7 @@ export class StateProvider {
|
|
|
244
244
|
const nextCallback = callbackQueue.dequeue();
|
|
245
245
|
if (nextCallback === undefined)
|
|
246
246
|
return Rejection.invalid(toState.error()).toPromise();
|
|
247
|
-
const callbackResult =
|
|
247
|
+
const callbackResult = Promise.resolve(
|
|
248
248
|
nextCallback(toState, fromState, injector),
|
|
249
249
|
);
|
|
250
250
|
return callbackResult
|
|
@@ -459,7 +459,7 @@ export class StateProvider {
|
|
|
459
459
|
if (error.type === RejectType.IGNORED) {
|
|
460
460
|
isLatest && this.urlService.update();
|
|
461
461
|
// Consider ignored `Transition.run()` as a successful `transitionTo`
|
|
462
|
-
return
|
|
462
|
+
return Promise.resolve(this.globals.current);
|
|
463
463
|
}
|
|
464
464
|
const detail = error.detail;
|
|
465
465
|
if (
|
|
@@ -474,12 +474,12 @@ export class StateProvider {
|
|
|
474
474
|
}
|
|
475
475
|
if (error.type === RejectType.ABORTED) {
|
|
476
476
|
isLatest && this.urlService.update();
|
|
477
|
-
return
|
|
477
|
+
return Promise.reject(error);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
const errorHandler = this.defaultErrorHandler();
|
|
481
481
|
errorHandler(error);
|
|
482
|
-
return
|
|
482
|
+
return Promise.reject(error);
|
|
483
483
|
};
|
|
484
484
|
const transition = this.transitionService.create(currentPath, ref);
|
|
485
485
|
const transitionToPromise = transition
|
|
@@ -12,8 +12,7 @@ describe("$state", () => {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async function initStateTo(state, params) {
|
|
15
|
-
const $state = $get("$state")
|
|
16
|
-
$q = $get("$q");
|
|
15
|
+
const $state = $get("$state");
|
|
17
16
|
return $state.transitionTo(state, params || {});
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -241,7 +240,7 @@ describe("$state", () => {
|
|
|
241
240
|
url: "/resolve-timeout/:foo",
|
|
242
241
|
resolve: {
|
|
243
242
|
value: function ($timeout) {
|
|
244
|
-
return
|
|
243
|
+
return setTimeout(function () {
|
|
245
244
|
log += "Success!";
|
|
246
245
|
}, 1);
|
|
247
246
|
},
|
|
@@ -311,7 +310,6 @@ describe("$state", () => {
|
|
|
311
310
|
_$state_,
|
|
312
311
|
_$stateParams_,
|
|
313
312
|
_$transitions_,
|
|
314
|
-
_$q_,
|
|
315
313
|
_$location_,
|
|
316
314
|
_$compile_,
|
|
317
315
|
_$stateRegistry_,
|
|
@@ -320,7 +318,6 @@ describe("$state", () => {
|
|
|
320
318
|
$state = _$state_;
|
|
321
319
|
$stateParams = _$stateParams_;
|
|
322
320
|
$transitions = _$transitions_;
|
|
323
|
-
$q = _$q_;
|
|
324
321
|
$location = _$location_;
|
|
325
322
|
$compile = _$compile_;
|
|
326
323
|
$stateRegistry = _$stateRegistry_;
|
|
@@ -115,22 +115,19 @@ export class Ng1ViewConfig {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
load() {
|
|
118
|
-
const $q = services.$q;
|
|
119
118
|
const context = new ResolveContext(this.path);
|
|
120
119
|
const params = this.path.reduce(
|
|
121
120
|
(acc, node) => Object.assign(acc, node.paramValues),
|
|
122
121
|
{},
|
|
123
122
|
);
|
|
124
|
-
const promises =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
return $q.all(promises).then((results) => {
|
|
123
|
+
const promises = [
|
|
124
|
+
Promise.resolve(this.factory.fromConfig(this.viewDecl, params, context)),
|
|
125
|
+
Promise.resolve(this.getController(context)),
|
|
126
|
+
];
|
|
127
|
+
return Promise.all(promises).then((results) => {
|
|
131
128
|
trace.traceViewServiceEvent("Loaded", this);
|
|
132
|
-
this.controller = results
|
|
133
|
-
Object.assign(this, results
|
|
129
|
+
this.controller = results[0];
|
|
130
|
+
Object.assign(this, results[1]); // Either { template: "tpl" } or { component: "cmpName" }
|
|
134
131
|
return this;
|
|
135
132
|
});
|
|
136
133
|
}
|
|
@@ -24,21 +24,18 @@ export class TemplateFactoryProvider {
|
|
|
24
24
|
"$http",
|
|
25
25
|
"$templateCache",
|
|
26
26
|
"$templateRequest",
|
|
27
|
-
"$q",
|
|
28
27
|
"$injector",
|
|
29
28
|
/**
|
|
30
29
|
* @param {any} $http
|
|
31
30
|
* @param {import("../core/cache/cache-factory").TemplateCache} $templateCache
|
|
32
31
|
* @param {any} $templateRequest
|
|
33
|
-
* @param {any} $q
|
|
34
32
|
* @param {import("../core/di/internal-injector").InjectorService} $injector
|
|
35
33
|
* @returns
|
|
36
34
|
*/
|
|
37
|
-
($http, $templateCache, $templateRequest, $
|
|
35
|
+
($http, $templateCache, $templateRequest, $injector) => {
|
|
38
36
|
this.$templateRequest = $templateRequest;
|
|
39
37
|
this.$http = $http;
|
|
40
38
|
this.$templateCache = $templateCache;
|
|
41
|
-
this.$q = $q;
|
|
42
39
|
this.$injector = $injector;
|
|
43
40
|
return this;
|
|
44
41
|
},
|
|
@@ -69,9 +66,9 @@ export class TemplateFactoryProvider {
|
|
|
69
66
|
fromConfig(config, params, context) {
|
|
70
67
|
const defaultTemplate = "<ui-view></ui-view>";
|
|
71
68
|
const asTemplate = (result) =>
|
|
72
|
-
|
|
69
|
+
Promise.resolve(result).then((str) => ({ template: str }));
|
|
73
70
|
const asComponent = (result) =>
|
|
74
|
-
|
|
71
|
+
Promise.resolve(result).then((str) => ({ component: str }));
|
|
75
72
|
|
|
76
73
|
const getConfigType = (config) => {
|
|
77
74
|
if (isDefined(config.template)) return "template";
|
|
@@ -36,7 +36,6 @@ describe("templateFactory", () => {
|
|
|
36
36
|
describe("should follow $sce policy and", () => {
|
|
37
37
|
it("accepts relative URLs", async () => {
|
|
38
38
|
let res = $templateFactory.fromUrl("mock/hello");
|
|
39
|
-
$scope.$digest();
|
|
40
39
|
await wait(100);
|
|
41
40
|
expect(res.$$state.status).toBe(1);
|
|
42
41
|
});
|
|
@@ -128,7 +127,6 @@ describe("templateFactory", () => {
|
|
|
128
127
|
it("should not prefix the components dom element with anything", async () => {
|
|
129
128
|
$stateRegistry.register({ name: "cmp", component: "myComponent" });
|
|
130
129
|
$stateService.go("cmp");
|
|
131
|
-
$scope.$digest();
|
|
132
130
|
await wait(100);
|
|
133
131
|
expect(el.html()).toMatch(/\<my-component/);
|
|
134
132
|
});
|
|
@@ -139,14 +137,12 @@ describe("templateFactory", () => {
|
|
|
139
137
|
component: "dataComponent",
|
|
140
138
|
});
|
|
141
139
|
$stateService.go("cmp");
|
|
142
|
-
$scope.$digest();
|
|
143
140
|
expect(el.html()).toMatch(/\<x-data-component/);
|
|
144
141
|
});
|
|
145
142
|
|
|
146
143
|
it("should prefix the components dom element with x- for components named xFoo", () => {
|
|
147
144
|
$stateRegistry.register({ name: "cmp", component: "xComponent" });
|
|
148
145
|
$stateService.go("cmp");
|
|
149
|
-
$scope.$digest();
|
|
150
146
|
expect(el.html()).toMatch(/\<x-x-component/);
|
|
151
147
|
});
|
|
152
148
|
});
|
|
@@ -37,7 +37,7 @@ export class TransitionHook {
|
|
|
37
37
|
// Chain the next hook off the previous
|
|
38
38
|
const createHookChainR = (prev, nextHook) =>
|
|
39
39
|
prev.then(() => nextHook.invokeHook());
|
|
40
|
-
return hooks.reduce(createHookChainR, waitFor ||
|
|
40
|
+
return hooks.reduce(createHookChainR, waitFor || Promise.resolve());
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Invokes all the provided TransitionHooks, in order.
|
|
@@ -49,7 +49,7 @@ export class Transition {
|
|
|
49
49
|
constructor(fromPath, targetState, transitionService, globals) {
|
|
50
50
|
this.globals = globals;
|
|
51
51
|
this.transitionService = transitionService;
|
|
52
|
-
this._deferred =
|
|
52
|
+
this._deferred = Promise.defer();
|
|
53
53
|
/**
|
|
54
54
|
* This promise is resolved or rejected based on the outcome of the Transition.
|
|
55
55
|
*
|
|
@@ -129,7 +129,7 @@ describe("view hooks", () => {
|
|
|
129
129
|
$state.defaultErrorHandler(function () {});
|
|
130
130
|
ctrl.prototype.uiCanExit = function () {
|
|
131
131
|
log += "canexit;";
|
|
132
|
-
return
|
|
132
|
+
return setTimeout(() => {
|
|
133
133
|
log += "delay;";
|
|
134
134
|
return false;
|
|
135
135
|
}, 1);
|
|
@@ -145,7 +145,7 @@ describe("view hooks", () => {
|
|
|
145
145
|
it("can wait for a promise and then allow the transition", async () => {
|
|
146
146
|
ctrl.prototype.uiCanExit = function () {
|
|
147
147
|
log += "canexit;";
|
|
148
|
-
return
|
|
148
|
+
return setTimeout(() => {
|
|
149
149
|
log += "delay;";
|
|
150
150
|
}, 1);
|
|
151
151
|
};
|
|
@@ -9,22 +9,20 @@ export class ViewScrollProvider {
|
|
|
9
9
|
|
|
10
10
|
$get = [
|
|
11
11
|
"$anchorScroll",
|
|
12
|
-
"$timeout",
|
|
13
12
|
/**
|
|
14
13
|
* @param {import('../services/anchor-scroll').AnchorScrollObject} $anchorScroll
|
|
15
|
-
* @param {*} $timeout
|
|
16
14
|
* @returns {import('../services/anchor-scroll').AnchorScrollObject|Function}
|
|
17
15
|
*/
|
|
18
|
-
($anchorScroll
|
|
16
|
+
($anchorScroll) => {
|
|
19
17
|
if (this.enabled) {
|
|
20
18
|
return $anchorScroll;
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* @param {import('../shared/jqlite/jqlite').JQLite} $element
|
|
24
|
-
* @returns {
|
|
22
|
+
* @returns {Promise<number>}
|
|
25
23
|
*/
|
|
26
|
-
return function ($element) {
|
|
27
|
-
return
|
|
24
|
+
return async function ($element) {
|
|
25
|
+
return setTimeout(
|
|
28
26
|
() => {
|
|
29
27
|
$element[0].scrollIntoView();
|
|
30
28
|
},
|