@angular-wave/angular.ts 0.0.19 → 0.0.21
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/README.md +3 -3
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/index.html +2 -1
- package/package.json +1 -1
- package/src/core/q.js +9 -9
- package/src/core/sanitize-uri.js +1 -1
- package/src/core/sce.js +1 -1
- package/src/public.js +0 -2
- package/src/router/stateProvider.js +2 -0
- package/test/router/state-filter.spec.js +146 -0
- package/test/directive/a.spec.js +0 -192
package/index.html
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
<!-- <script src="dist/angular-ts.umd.js"></script> -->
|
|
18
18
|
<!-- include spec files here... -->
|
|
19
19
|
|
|
20
|
-
<script type="module" src="test/directive/a.spec.js"></script>
|
|
21
20
|
<script type="module" src="test/directive/boolean.spec.js"></script>
|
|
22
21
|
<script type="module" src="test/directive/form.spec.js"></script>
|
|
23
22
|
<script type="module" src="test/directive/input.spec.js"></script>
|
|
@@ -100,7 +99,9 @@
|
|
|
100
99
|
|
|
101
100
|
<!-- Router specs-->
|
|
102
101
|
<script type="module" src="test/router/glob.spec.js"></script>
|
|
102
|
+
<script type="module" src="test/router/state-filter.spec.js"></script>
|
|
103
103
|
<script type="module" src="test/router/state.spec.js"></script>
|
|
104
|
+
|
|
104
105
|
|
|
105
106
|
|
|
106
107
|
<!-- Run asyncs last to prevent digest polution-->
|
package/package.json
CHANGED
package/src/core/q.js
CHANGED
|
@@ -328,7 +328,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
function Deferred() {
|
|
331
|
-
const promise = (this.promise = new
|
|
331
|
+
const promise = (this.promise = new QPromise());
|
|
332
332
|
// Non prototype methods necessary to support unbound execution :/
|
|
333
333
|
this.resolve = function (val) {
|
|
334
334
|
resolvePromise(promise, val);
|
|
@@ -341,11 +341,11 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
function
|
|
344
|
+
function QPromise() {
|
|
345
345
|
this.$$state = { status: 0 };
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
extend(
|
|
348
|
+
extend(QPromise.prototype, {
|
|
349
349
|
then(onFulfilled, onRejected, progressBack) {
|
|
350
350
|
if (
|
|
351
351
|
isUndefined(onFulfilled) &&
|
|
@@ -354,7 +354,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
354
354
|
) {
|
|
355
355
|
return this;
|
|
356
356
|
}
|
|
357
|
-
const result = new
|
|
357
|
+
const result = new QPromise();
|
|
358
358
|
|
|
359
359
|
this.$$state.pending = this.$$state.pending || [];
|
|
360
360
|
this.$$state.pending.push([
|
|
@@ -572,7 +572,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
572
572
|
* @returns {Promise} Returns a promise that was already resolved as rejected with the `reason`.
|
|
573
573
|
*/
|
|
574
574
|
function reject(reason) {
|
|
575
|
-
const result = new
|
|
575
|
+
const result = new QPromise();
|
|
576
576
|
rejectPromise(result, reason);
|
|
577
577
|
return result;
|
|
578
578
|
}
|
|
@@ -608,7 +608,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
608
608
|
*/
|
|
609
609
|
|
|
610
610
|
function when(value, callback, errback, progressBack) {
|
|
611
|
-
const result = new
|
|
611
|
+
const result = new QPromise();
|
|
612
612
|
resolvePromise(result, value);
|
|
613
613
|
return result.then(callback, errback, progressBack);
|
|
614
614
|
}
|
|
@@ -646,7 +646,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
646
646
|
*/
|
|
647
647
|
|
|
648
648
|
function all(promises) {
|
|
649
|
-
const result = new
|
|
649
|
+
const result = new QPromise();
|
|
650
650
|
let counter = 0;
|
|
651
651
|
const results = Array.isArray(promises) ? [] : {};
|
|
652
652
|
|
|
@@ -699,7 +699,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
699
699
|
throw $qMinErr("norslvr", "Expected resolverFn, got '{0}'", resolver);
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
-
const promise = new
|
|
702
|
+
const promise = new QPromise();
|
|
703
703
|
|
|
704
704
|
function resolveFn(value) {
|
|
705
705
|
resolvePromise(promise, value);
|
|
@@ -716,7 +716,7 @@ function qFactory(nextTick, exceptionHandler, errorOnUnhandledRejections) {
|
|
|
716
716
|
|
|
717
717
|
// Let's make the instanceof operator work for promises, so that
|
|
718
718
|
// `new $q(fn) instanceof $q` would evaluate to true.
|
|
719
|
-
$Q.prototype =
|
|
719
|
+
$Q.prototype = QPromise.prototype;
|
|
720
720
|
|
|
721
721
|
$Q.defer = defer;
|
|
722
722
|
$Q.reject = reject;
|
package/src/core/sanitize-uri.js
CHANGED
|
@@ -28,7 +28,7 @@ export function SanitizeUriProvider() {
|
|
|
28
28
|
* to the DOM it is inactive and potentially malicious code will not be executed.
|
|
29
29
|
*
|
|
30
30
|
* @param {RegExp=} regexp New regexp to trust urls with.
|
|
31
|
-
* @returns {RegExp|ng
|
|
31
|
+
* @returns {RegExp|ng.ICompileProvider} Current RegExp if called without value or self for
|
|
32
32
|
* chaining otherwise.
|
|
33
33
|
*/
|
|
34
34
|
this.aHrefSanitizationTrustedUrlList = function (regexp) {
|
package/src/core/sce.js
CHANGED
|
@@ -487,7 +487,7 @@ export function $SceDelegateProvider() {
|
|
|
487
487
|
);
|
|
488
488
|
} else if (type === SCE_CONTEXTS.HTML) {
|
|
489
489
|
// htmlSanitizer throws its own error when no sanitizer is available.
|
|
490
|
-
return htmlSanitizer(
|
|
490
|
+
return htmlSanitizer();
|
|
491
491
|
}
|
|
492
492
|
// Default error when the $sce service has no way to make the input safe.
|
|
493
493
|
throw $sceMinErr(
|
package/src/public.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $CompileProvider } from "./core/compile";
|
|
2
|
-
import { htmlAnchorDirective } from "./directive/a";
|
|
3
2
|
import {
|
|
4
3
|
inputDirective,
|
|
5
4
|
ngValueDirective,
|
|
@@ -117,7 +116,6 @@ export function publishExternalAPI() {
|
|
|
117
116
|
$provide
|
|
118
117
|
.provider("$compile", $CompileProvider)
|
|
119
118
|
.directive({
|
|
120
|
-
a: htmlAnchorDirective,
|
|
121
119
|
input: inputDirective,
|
|
122
120
|
textarea: inputDirective,
|
|
123
121
|
form: formDirective,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Angular } from "../../src/loader";
|
|
2
|
+
import { publishExternalAPI } from "../../src/public";
|
|
3
|
+
|
|
4
|
+
describe("router filters", function () {
|
|
5
|
+
let module, $parse, $state, $q, $rootScope, $location;
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
window.angular = new Angular();
|
|
9
|
+
publishExternalAPI();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterEach(() => (window.location.hash = "#!"));
|
|
13
|
+
|
|
14
|
+
describe("isState filter", () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
module = window.angular.module("defaultModule", ["ui.router"]);
|
|
17
|
+
module.config(function ($stateProvider) {
|
|
18
|
+
$stateProvider
|
|
19
|
+
.state({ name: "a", url: "/" })
|
|
20
|
+
.state({ name: "a.b", url: "/b" })
|
|
21
|
+
.state({ name: "with-param", url: "/with/:param" });
|
|
22
|
+
});
|
|
23
|
+
let $injector = window.angular.bootstrap(
|
|
24
|
+
document.getElementById("dummy"),
|
|
25
|
+
["defaultModule"],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
$injector.invoke(
|
|
29
|
+
(
|
|
30
|
+
_$parse_,
|
|
31
|
+
_$state_,
|
|
32
|
+
_$rootScope_,
|
|
33
|
+
_$transitions_,
|
|
34
|
+
_$q_,
|
|
35
|
+
_$location_,
|
|
36
|
+
_$compile_,
|
|
37
|
+
_$router_,
|
|
38
|
+
) => {
|
|
39
|
+
$parse = _$parse_;
|
|
40
|
+
$state = _$state_;
|
|
41
|
+
$rootScope = _$rootScope_;
|
|
42
|
+
$q = _$q_;
|
|
43
|
+
$location = _$location_;
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
it("should return true if the current state exactly matches the input state", async () => {
|
|
48
|
+
await $state.go("a");
|
|
49
|
+
expect($parse('"a" | isState')($rootScope)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should return false if the current state does not exactly match the input state", async () => {
|
|
53
|
+
await $state.go("a.b");
|
|
54
|
+
expect($parse('"a" | isState')($rootScope)).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should return true if the current state and param matches the input state", async () => {
|
|
58
|
+
await $state.go("with-param", { param: "a" });
|
|
59
|
+
|
|
60
|
+
expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(
|
|
61
|
+
true,
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should return false if the current state and param does not match the input state", async () => {
|
|
66
|
+
await $state.go("with-param", { param: "b" });
|
|
67
|
+
|
|
68
|
+
expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(
|
|
69
|
+
false,
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("includedByState filter", function () {
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
module = window.angular.module("defaultModule", ["ui.router"]);
|
|
77
|
+
module.config(function ($stateProvider) {
|
|
78
|
+
$stateProvider
|
|
79
|
+
.state({ name: "a", url: "/" })
|
|
80
|
+
.state({ name: "a.b", url: "/b" })
|
|
81
|
+
.state({ name: "c", url: "/c" })
|
|
82
|
+
.state({ name: "d", url: "/d/:id" });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
let $injector = window.angular.bootstrap(
|
|
86
|
+
document.getElementById("dummy"),
|
|
87
|
+
["defaultModule"],
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
$injector.invoke(
|
|
91
|
+
(
|
|
92
|
+
_$parse_,
|
|
93
|
+
_$state_,
|
|
94
|
+
_$rootScope_,
|
|
95
|
+
_$transitions_,
|
|
96
|
+
_$q_,
|
|
97
|
+
_$location_,
|
|
98
|
+
_$compile_,
|
|
99
|
+
_$router_,
|
|
100
|
+
) => {
|
|
101
|
+
$parse = _$parse_;
|
|
102
|
+
$state = _$state_;
|
|
103
|
+
$rootScope = _$rootScope_;
|
|
104
|
+
$q = _$q_;
|
|
105
|
+
$location = _$location_;
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
afterEach(() => (window.location.hash = "#!"));
|
|
111
|
+
|
|
112
|
+
it("should return true if the current state exactly matches the input state", async () => {
|
|
113
|
+
await $state.go("a");
|
|
114
|
+
|
|
115
|
+
expect($parse('"a" | includedByState')($rootScope)).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("should return true if the current state includes the input state", async () => {
|
|
119
|
+
await $state.go("a.b");
|
|
120
|
+
|
|
121
|
+
expect($parse('"a" | includedByState')($rootScope)).toBe(true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should return false if the current state does not include input state", async () => {
|
|
125
|
+
await $state.go("c");
|
|
126
|
+
|
|
127
|
+
expect($parse('"a" | includedByState')($rootScope)).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should return true if the current state include input state and params", async () => {
|
|
131
|
+
await $state.go("d", { id: 123 });
|
|
132
|
+
|
|
133
|
+
expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(
|
|
134
|
+
true,
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("should return false if the current state does not include input state and params", async () => {
|
|
139
|
+
await $state.go("d", { id: 2377 });
|
|
140
|
+
|
|
141
|
+
expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(
|
|
142
|
+
false,
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
package/test/directive/a.spec.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { publishExternalAPI } from "../../src/public";
|
|
2
|
-
import { createInjector } from "../../src/injector";
|
|
3
|
-
import { dealoc, jqLite } from "../../src/jqLite";
|
|
4
|
-
import { valueFn, isDefined } from "../../src/shared/utils";
|
|
5
|
-
|
|
6
|
-
describe("a", () => {
|
|
7
|
-
let element;
|
|
8
|
-
let $compile;
|
|
9
|
-
let $rootScope;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
publishExternalAPI();
|
|
13
|
-
createInjector([
|
|
14
|
-
"ng",
|
|
15
|
-
function ($compileProvider) {
|
|
16
|
-
$compileProvider
|
|
17
|
-
.directive(
|
|
18
|
-
"linkTo",
|
|
19
|
-
valueFn({
|
|
20
|
-
restrict: "A",
|
|
21
|
-
template:
|
|
22
|
-
'<div class="my-link"><a href="{{destination}}">{{destination}}</a></div>',
|
|
23
|
-
replace: true,
|
|
24
|
-
scope: {
|
|
25
|
-
destination: "@linkTo",
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
)
|
|
29
|
-
.directive(
|
|
30
|
-
"linkNot",
|
|
31
|
-
valueFn({
|
|
32
|
-
restrict: "A",
|
|
33
|
-
template:
|
|
34
|
-
'<div class="my-link"><a href>{{destination}}</a></div>',
|
|
35
|
-
replace: true,
|
|
36
|
-
scope: {
|
|
37
|
-
destination: "@linkNot",
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
},
|
|
42
|
-
]).invoke((_$compile_, _$rootScope_) => {
|
|
43
|
-
$compile = _$compile_;
|
|
44
|
-
$rootScope = _$rootScope_;
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
afterEach(() => {
|
|
49
|
-
dealoc(element);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should prevent default action to be executed when href is empty", () => {
|
|
53
|
-
const orgLocation = window.document.location.href;
|
|
54
|
-
let preventDefaultCalled = false;
|
|
55
|
-
let event;
|
|
56
|
-
|
|
57
|
-
element = $compile('<a href="">empty link</a>')($rootScope);
|
|
58
|
-
|
|
59
|
-
event = window.document.createEvent("MouseEvent");
|
|
60
|
-
event.initMouseEvent(
|
|
61
|
-
"click",
|
|
62
|
-
true,
|
|
63
|
-
true,
|
|
64
|
-
window,
|
|
65
|
-
0,
|
|
66
|
-
0,
|
|
67
|
-
0,
|
|
68
|
-
0,
|
|
69
|
-
0,
|
|
70
|
-
false,
|
|
71
|
-
false,
|
|
72
|
-
false,
|
|
73
|
-
false,
|
|
74
|
-
0,
|
|
75
|
-
null,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
event.preventDefaultOrg = event.preventDefault;
|
|
79
|
-
event.preventDefault = function () {
|
|
80
|
-
preventDefaultCalled = true;
|
|
81
|
-
if (this.preventDefaultOrg) this.preventDefaultOrg();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
element[0].dispatchEvent(event);
|
|
85
|
-
|
|
86
|
-
expect(preventDefaultCalled).toEqual(true);
|
|
87
|
-
|
|
88
|
-
expect(window.document.location.href).toEqual(orgLocation);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("should not link and hookup an event if href is present at compile", () => {
|
|
92
|
-
const jq = jqLite;
|
|
93
|
-
element = jq('<a href="//a.com">hello@you</a>');
|
|
94
|
-
const linker = $compile(element);
|
|
95
|
-
|
|
96
|
-
spyOn(jq.prototype, "on");
|
|
97
|
-
|
|
98
|
-
linker($rootScope);
|
|
99
|
-
|
|
100
|
-
expect(jq.prototype.on).not.toHaveBeenCalled();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("should not preventDefault if anchor element is replaced with href-containing element", () => {
|
|
104
|
-
spyOn(jqLite.prototype, "on").and.callThrough();
|
|
105
|
-
element = $compile('<a link-to="https://www.google.com">')($rootScope);
|
|
106
|
-
$rootScope.$digest();
|
|
107
|
-
|
|
108
|
-
const child = element.children("a");
|
|
109
|
-
const preventDefault = jasmine.createSpy("preventDefault");
|
|
110
|
-
|
|
111
|
-
child.triggerHandler({
|
|
112
|
-
type: "click",
|
|
113
|
-
preventDefault,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
expect(preventDefault).not.toHaveBeenCalled();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("should preventDefault if anchor element is replaced with element without href attribute", () => {
|
|
120
|
-
spyOn(jqLite.prototype, "on").and.callThrough();
|
|
121
|
-
element = $compile('<a link-not="https://www.google.com">')($rootScope);
|
|
122
|
-
$rootScope.$digest();
|
|
123
|
-
|
|
124
|
-
const child = element.children("a");
|
|
125
|
-
const preventDefault = jasmine.createSpy("preventDefault");
|
|
126
|
-
|
|
127
|
-
child.triggerHandler({
|
|
128
|
-
type: "click",
|
|
129
|
-
preventDefault,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
expect(preventDefault).toHaveBeenCalled();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
if (isDefined(window.SVGElement)) {
|
|
136
|
-
describe("SVGAElement", () => {
|
|
137
|
-
it("should prevent default action to be executed when href is empty", () => {
|
|
138
|
-
const orgLocation = window.document.location.href;
|
|
139
|
-
let preventDefaultCalled = false;
|
|
140
|
-
let event;
|
|
141
|
-
let child;
|
|
142
|
-
|
|
143
|
-
element = $compile('<svg><a xlink:href="">empty link</a></svg>')(
|
|
144
|
-
$rootScope,
|
|
145
|
-
);
|
|
146
|
-
child = element.children("a");
|
|
147
|
-
|
|
148
|
-
event = window.document.createEvent("MouseEvent");
|
|
149
|
-
event.initMouseEvent(
|
|
150
|
-
"click",
|
|
151
|
-
true,
|
|
152
|
-
true,
|
|
153
|
-
window,
|
|
154
|
-
0,
|
|
155
|
-
0,
|
|
156
|
-
0,
|
|
157
|
-
0,
|
|
158
|
-
0,
|
|
159
|
-
false,
|
|
160
|
-
false,
|
|
161
|
-
false,
|
|
162
|
-
false,
|
|
163
|
-
0,
|
|
164
|
-
null,
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
event.preventDefaultOrg = event.preventDefault;
|
|
168
|
-
event.preventDefault = function () {
|
|
169
|
-
preventDefaultCalled = true;
|
|
170
|
-
if (this.preventDefaultOrg) this.preventDefaultOrg();
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
child[0].dispatchEvent(event);
|
|
174
|
-
|
|
175
|
-
expect(preventDefaultCalled).toEqual(true);
|
|
176
|
-
expect(window.document.location.href).toEqual(orgLocation);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("should not link and hookup an event if xlink:href is present at compile", () => {
|
|
180
|
-
const jq = jqLite;
|
|
181
|
-
element = jq('<svg><a xlink:href="bobby">hello@you</a></svg>');
|
|
182
|
-
const linker = $compile(element);
|
|
183
|
-
|
|
184
|
-
spyOn(jq.prototype, "on");
|
|
185
|
-
|
|
186
|
-
linker($rootScope);
|
|
187
|
-
|
|
188
|
-
expect(jq.prototype.on).not.toHaveBeenCalled();
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|