@angular-wave/angular.ts 0.0.22 → 0.0.24

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.
Files changed (71) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/index.html +6 -2
  4. package/package.json +1 -1
  5. package/src/core/compile.js +2 -3
  6. package/src/core/parser/parse.js +2 -3
  7. package/src/filters/order-by.js +8 -8
  8. package/src/router/directives/{stateDirectives.js → state-directives.js} +1 -2
  9. package/src/router/directives/{viewDirective.js → view-directive.js} +4 -12
  10. package/src/router/globals.js +1 -1
  11. package/src/router/hooks/{ignoredTransition.js → ignored-transition.js} +1 -1
  12. package/src/router/hooks/{redirectTo.js → redirect-to.js} +1 -1
  13. package/src/router/hooks/resolve.js +1 -1
  14. package/src/router/index.js +6 -8
  15. package/src/router/params/{paramTypes.js → param-types.js} +3 -4
  16. package/src/router/params/param.js +1 -1
  17. package/src/router/path/{pathUtils.js → path-utils.js} +2 -2
  18. package/src/router/resolve/resolvable.js +2 -2
  19. package/src/router/resolve/{resolveContext.js → resolve-context.js} +1 -1
  20. package/src/router/router.js +8 -8
  21. package/src/router/services.js +3 -3
  22. package/src/router/state/{stateBuilder.js → state-builder.js} +2 -3
  23. package/src/router/state/{stateQueueManager.js → state-queue-manager.js} +2 -1
  24. package/src/router/state/{stateRegistry.js → state-registry.js} +3 -3
  25. package/src/router/state/{stateService.js → state-service.js} +7 -7
  26. package/src/router/state/views.js +1 -1
  27. package/src/router/{stateProvider.js → state-provider.js} +8 -0
  28. package/src/router/{templateFactory.js → template-factory.js} +93 -51
  29. package/src/router/transition/{hookBuilder.js → hook-builder.js} +3 -3
  30. package/src/router/transition/{transitionEventType.js → transition-event-type.js} +1 -1
  31. package/src/router/transition/{transitionHook.js → transition-hook.js} +2 -2
  32. package/src/router/transition/{transitionService.js → transition-service.js} +10 -10
  33. package/src/router/transition/transition.js +12 -9
  34. package/src/router/url/{urlConfig.js → url-config.js} +1 -1
  35. package/src/router/url/{urlMatcherFactory.js → url-matcher-factory.js} +1 -1
  36. package/src/router/url/{urlMatcher.js → url-matcher.js} +0 -2
  37. package/src/router/url/{urlRouter.js → url-router.js} +1 -1
  38. package/src/router/url/{urlRule.js → url-rule.js} +13 -5
  39. package/src/router/url/{urlRules.js → url-rules.js} +3 -3
  40. package/src/router/url/{urlService.js → url-service.js} +6 -6
  41. package/src/services/browser.js +3 -18
  42. package/src/shared/strings.js +2 -2
  43. package/test/router/ng-state-builder.spec.js +81 -0
  44. package/test/router/services.spec.js +0 -1
  45. package/test/router/state-directives.spec.js +867 -893
  46. package/test/router/template-factory.spec.js +146 -0
  47. package/test/router/url-matcher-factory.spec.js +1313 -0
  48. package/test/router/view-directive.spec.js +2013 -0
  49. package/test/router/view-hook.spec.js +217 -0
  50. package/test/router/view-scroll.spec.js +77 -0
  51. package/test/router/view.spec.js +117 -0
  52. package/test/test-utils.js +9 -0
  53. package/types/router/legacy/resolveService.d.ts +1 -1
  54. package/types/router/statebuilders/onEnterExitRetain.d.ts +1 -1
  55. package/types/router/statebuilders/views.d.ts +1 -2
  56. /package/src/router/hooks/{coreResolvables.js → core-resolvables.js} +0 -0
  57. /package/src/router/hooks/{invalidTransition.js → invalid-transition.js} +0 -0
  58. /package/src/router/hooks/{lazyLoad.js → lazy-load.js} +0 -0
  59. /package/src/router/hooks/{onEnterExitRetain.js → on-enter-exit-retain.js} +0 -0
  60. /package/src/router/hooks/{updateGlobals.js → update-globals.js} +0 -0
  61. /package/src/router/{locationServices.js → location-services.js} +0 -0
  62. /package/src/router/params/{paramType.js → param-type.js} +0 -0
  63. /package/src/router/params/{stateParams.js → state-params.js} +0 -0
  64. /package/src/router/path/{pathNode.js → path-node.js} +0 -0
  65. /package/src/router/state/{stateMatcher.js → state-matcher.js} +0 -0
  66. /package/src/router/state/{stateObject.js → state-object.js} +0 -0
  67. /package/src/router/state/{targetState.js → target-state.js} +0 -0
  68. /package/src/router/{stateFilters.js → state-filters.js} +0 -0
  69. /package/src/router/transition/{hookRegistry.js → hook-registry.js} +0 -0
  70. /package/src/router/transition/{rejectFactory.js → reject-factory.js} +0 -0
  71. /package/src/router/{viewScroll.js → view-scroll.js} +0 -0
@@ -0,0 +1,146 @@
1
+ import { dealoc, jqLite } from "../../src/jqLite";
2
+ import { Angular } from "../../src/loader";
3
+ import { publishExternalAPI } from "../../src/public";
4
+ import { wait } from "../test-utils";
5
+
6
+ describe("templateFactory", () => {
7
+ let $injector, $templateFactory, $httpBackend, $sce, $scope, $compile;
8
+
9
+ beforeEach(() => {
10
+ dealoc(document.getElementById("dummy"));
11
+ window.angular = new Angular();
12
+ publishExternalAPI();
13
+ window.angular.module("defaultModule", ["ui.router"]);
14
+ $injector = window.angular.bootstrap(document.getElementById("dummy"), [
15
+ "defaultModule",
16
+ ]);
17
+ $injector.invoke(
18
+ (_$templateFactory_, _$httpBackend_, _$sce_, $rootScope) => {
19
+ ($templateFactory = _$templateFactory_),
20
+ ($httpBackend = _$httpBackend_),
21
+ ($sce = _$sce_);
22
+ $scope = $rootScope;
23
+ },
24
+ );
25
+ });
26
+
27
+ it("exists", () => {
28
+ expect($injector.get("$templateFactory")).toBeDefined();
29
+ });
30
+
31
+ describe("should follow $sce policy and", () => {
32
+ it("accepts relative URLs", async () => {
33
+ let res = $templateFactory.fromUrl("mock/hello");
34
+ $scope.$digest();
35
+ await wait(10);
36
+ expect(res.$$state.status).toBe(1);
37
+ });
38
+
39
+ it("rejects untrusted URLs", () => {
40
+ let error = "No error thrown";
41
+ try {
42
+ $templateFactory.fromUrl("http://evil.com/views/view.html");
43
+ } catch (e) {
44
+ error = e.message;
45
+ }
46
+ expect(error).toMatch(/sce:insecurl/);
47
+ });
48
+
49
+ it("accepts explicitly trusted URLs", () => {
50
+ expect(() => {
51
+ $templateFactory.fromUrl(
52
+ $sce.trustAsResourceUrl("http://evil.com/views/view.html"),
53
+ );
54
+ }).not.toThrowError();
55
+ });
56
+ });
57
+
58
+ describe("templateFactory with forced use of $http service", () => {
59
+ beforeEach(() => {
60
+ dealoc(document.getElementById("dummy"));
61
+ let module = window.angular.module("defaultModule", ["ui.router"]);
62
+ module.config(function ($templateFactoryProvider) {
63
+ $templateFactoryProvider.useHttpService(true);
64
+ });
65
+ $injector = window.angular.bootstrap(document.getElementById("dummy"), [
66
+ "defaultModule",
67
+ ]);
68
+ $injector.invoke(
69
+ (_$templateFactory_, _$httpBackend_, _$sce_, $rootScope) => {
70
+ ($templateFactory = _$templateFactory_),
71
+ ($httpBackend = _$httpBackend_),
72
+ ($sce = _$sce_);
73
+ $scope = $rootScope;
74
+ },
75
+ );
76
+ });
77
+
78
+ it("does not restrict URL loading", function () {
79
+ expect(() => {
80
+ $templateFactory.fromUrl("http://evil.com/views/view.html");
81
+ }).not.toThrowError();
82
+
83
+ expect(() => {
84
+ $templateFactory.fromUrl("data:text/html,foo");
85
+ }).not.toThrowError();
86
+ });
87
+ });
88
+
89
+ describe("component template builder", () => {
90
+ let $router, el;
91
+
92
+ beforeEach(() => {
93
+ dealoc(document.getElementById("dummy"));
94
+ const mod = angular.module("defaultModule", ["ui.router"]);
95
+ mod.component("myComponent", { template: "hi" });
96
+ mod.component("dataComponent", { template: "hi" });
97
+ mod.component("xComponent", { template: "hi" });
98
+ $injector = window.angular.bootstrap(document.getElementById("dummy"), [
99
+ "defaultModule",
100
+ ]);
101
+ $injector.invoke(
102
+ (
103
+ _$templateFactory_,
104
+ _$httpBackend_,
105
+ _$sce_,
106
+ $rootScope,
107
+ _$router_,
108
+ _$compile_,
109
+ ) => {
110
+ ($templateFactory = _$templateFactory_),
111
+ ($httpBackend = _$httpBackend_),
112
+ ($sce = _$sce_);
113
+ $scope = $rootScope;
114
+ $router = _$router_;
115
+ $compile = _$compile_;
116
+ },
117
+ );
118
+ el = $compile(jqLite("<div><ui-view></ui-view></div>"))($scope.$new());
119
+ });
120
+
121
+ it("should not prefix the components dom element with anything", async () => {
122
+ $router.stateRegistry.register({ name: "cmp", component: "myComponent" });
123
+ $router.stateService.go("cmp");
124
+ $scope.$digest();
125
+ await wait(10);
126
+ expect(el.html()).toMatch(/\<my-component/);
127
+ });
128
+
129
+ it("should prefix the components dom element with x- for components named dataFoo", () => {
130
+ $router.stateRegistry.register({
131
+ name: "cmp",
132
+ component: "dataComponent",
133
+ });
134
+ $router.stateService.go("cmp");
135
+ $scope.$digest();
136
+ expect(el.html()).toMatch(/\<x-data-component/);
137
+ });
138
+
139
+ it("should prefix the components dom element with x- for components named xFoo", () => {
140
+ $router.stateRegistry.register({ name: "cmp", component: "xComponent" });
141
+ $router.stateService.go("cmp");
142
+ $scope.$digest();
143
+ expect(el.html()).toMatch(/\<x-x-component/);
144
+ });
145
+ });
146
+ });