@angular-wave/angular.ts 0.4.5 → 0.4.6
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 +1 -0
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/core/compile/compile.js +8 -11
- package/src/core/interpolate/interpolate.js +10 -13
- package/src/core/location/location.js +6 -20
- package/src/directive/events/events.html +1 -0
- package/src/directive/observe/observe.js +4 -1
- package/src/directive/observe/observe.spec.js +21 -0
- package/src/directive/observe/test.html +3 -11
- package/types/core/location/location.d.ts +1 -3
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.4.
|
|
5
|
+
"version": "0.4.6",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
|
@@ -2394,7 +2394,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2394
2394
|
});
|
|
2395
2395
|
|
|
2396
2396
|
return function delayedNodeLinkFn(
|
|
2397
|
-
|
|
2397
|
+
_ignoreChildLinkFn,
|
|
2398
2398
|
scope,
|
|
2399
2399
|
node,
|
|
2400
2400
|
rootElement,
|
|
@@ -2453,19 +2453,16 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2453
2453
|
}
|
|
2454
2454
|
|
|
2455
2455
|
function addTextInterpolateDirective(directives, text) {
|
|
2456
|
-
const interpolateFn = $interpolate(text, true);
|
|
2456
|
+
const interpolateFn = $interpolate(text, true); // Create interpolation function
|
|
2457
2457
|
if (interpolateFn) {
|
|
2458
2458
|
directives.push({
|
|
2459
2459
|
priority: 0,
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
node[0].nodeValue = value;
|
|
2467
|
-
});
|
|
2468
|
-
};
|
|
2460
|
+
// When transcluding a template that has bindings in the root
|
|
2461
|
+
// we don't have a parent and thus need to add the class during linking fn.
|
|
2462
|
+
compile: () => (scope, node) => {
|
|
2463
|
+
scope.$watch(interpolateFn, (value) => {
|
|
2464
|
+
node[0].nodeValue = value; // Update text node with new interpolated value
|
|
2465
|
+
});
|
|
2469
2466
|
},
|
|
2470
2467
|
});
|
|
2471
2468
|
}
|
|
@@ -353,19 +353,16 @@ export class InterpolateProvider {
|
|
|
353
353
|
expressions,
|
|
354
354
|
$$watchDelegate(scope, listener) {
|
|
355
355
|
let lastValue;
|
|
356
|
-
return scope.$watchGroup(
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
lastValue = currValue;
|
|
367
|
-
},
|
|
368
|
-
);
|
|
356
|
+
return scope.$watchGroup(parseFns, (values, oldValues) => {
|
|
357
|
+
const currValue = compute(values);
|
|
358
|
+
listener.call(
|
|
359
|
+
this,
|
|
360
|
+
currValue,
|
|
361
|
+
values !== oldValues ? lastValue : currValue,
|
|
362
|
+
scope,
|
|
363
|
+
);
|
|
364
|
+
lastValue = currValue;
|
|
365
|
+
});
|
|
369
366
|
},
|
|
370
367
|
},
|
|
371
368
|
);
|
|
@@ -42,6 +42,8 @@ export class Location {
|
|
|
42
42
|
* @param {string} appBaseNoFile application base URL stripped of any filename
|
|
43
43
|
*/
|
|
44
44
|
constructor(appBase, appBaseNoFile) {
|
|
45
|
+
const parsedUrl = urlResolve(appBase);
|
|
46
|
+
|
|
45
47
|
/** @type {string} */
|
|
46
48
|
this.appBase = appBase;
|
|
47
49
|
|
|
@@ -67,16 +69,17 @@ export class Location {
|
|
|
67
69
|
this.$$replace = false;
|
|
68
70
|
|
|
69
71
|
/** @type {import('../url-utils/url-utils').HttpProtocol} */
|
|
70
|
-
this.$$protocol =
|
|
72
|
+
this.$$protocol = parsedUrl.protocol;
|
|
71
73
|
|
|
72
74
|
/** @type {string} */
|
|
73
|
-
this.$$host =
|
|
75
|
+
this.$$host = parsedUrl.hostname;
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* The port, without ":"
|
|
77
79
|
* @type {number}
|
|
78
80
|
*/
|
|
79
|
-
this.$$port =
|
|
81
|
+
this.$$port =
|
|
82
|
+
toInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
|
|
80
83
|
|
|
81
84
|
/**
|
|
82
85
|
* The pathname, beginning with "/"
|
|
@@ -359,7 +362,6 @@ export class LocationHtml5Url extends Location {
|
|
|
359
362
|
super(appBase, appBaseNoFile);
|
|
360
363
|
this.$$html5 = true;
|
|
361
364
|
this.basePrefix = basePrefix || "";
|
|
362
|
-
parseAbsoluteUrl(appBase, this);
|
|
363
365
|
}
|
|
364
366
|
|
|
365
367
|
/**
|
|
@@ -442,10 +444,7 @@ export class LocationHtml5Url extends Location {
|
|
|
442
444
|
export class LocationHashbangUrl extends Location {
|
|
443
445
|
constructor(appBase, appBaseNoFile, hashPrefix) {
|
|
444
446
|
super(appBase, appBaseNoFile);
|
|
445
|
-
this.appBase = appBase;
|
|
446
|
-
this.appBaseNoFile = appBaseNoFile;
|
|
447
447
|
this.hashPrefix = hashPrefix;
|
|
448
|
-
parseAbsoluteUrl(appBase, this);
|
|
449
448
|
}
|
|
450
449
|
|
|
451
450
|
/**
|
|
@@ -890,19 +889,6 @@ function normalizePath(pathValue, searchValue, hashValue) {
|
|
|
890
889
|
return path + (search ? `?${search}` : "") + hash;
|
|
891
890
|
}
|
|
892
891
|
|
|
893
|
-
/**
|
|
894
|
-
* @param {string} absoluteUrl
|
|
895
|
-
* @param {Location} locationObj
|
|
896
|
-
*/
|
|
897
|
-
function parseAbsoluteUrl(absoluteUrl, locationObj) {
|
|
898
|
-
const parsedUrl = urlResolve(absoluteUrl);
|
|
899
|
-
|
|
900
|
-
locationObj.$$protocol = parsedUrl.protocol;
|
|
901
|
-
locationObj.$$host = parsedUrl.hostname;
|
|
902
|
-
locationObj.$$port =
|
|
903
|
-
toInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
892
|
function parseAppUrl(url, locationObj, html5Mode) {
|
|
907
893
|
if (/^\s*[\\/]{2,}/.test(url)) {
|
|
908
894
|
throw $locationMinErr("badpath", 'Invalid url "{0}".', url);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
|
|
12
12
|
<script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
|
|
13
13
|
<script type="module" src="/src/directive/events/event.spec.js"></script>
|
|
14
|
+
<script type="module" src="/src/directive/events/click.spec.js"></script>
|
|
14
15
|
</head>
|
|
15
16
|
<body>
|
|
16
17
|
<div id="dummy"></div>
|
|
@@ -6,8 +6,11 @@ export function ngObserveDirective() {
|
|
|
6
6
|
restrict: "A",
|
|
7
7
|
link: (scope, element, attrs) => {
|
|
8
8
|
const targetElement = element[0];
|
|
9
|
-
const prop = targetElement.dataset["update"];
|
|
10
9
|
const source = attrs["ngObserve"];
|
|
10
|
+
let prop = targetElement.dataset["update"];
|
|
11
|
+
if (!prop) {
|
|
12
|
+
prop = source;
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
if (!scope[prop]) {
|
|
13
16
|
scope[prop] = targetElement.getAttribute(source);
|
|
@@ -89,4 +89,25 @@ describe("observe", () => {
|
|
|
89
89
|
|
|
90
90
|
expect(observerSpy.disconnect).toHaveBeenCalled();
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
it("should observe attribute changes and update the same scope name if data-update attribute is absent", () => {
|
|
94
|
+
$scope.myProp = "";
|
|
95
|
+
const template = `<div ng-observe="test-attribute"></div>`;
|
|
96
|
+
element = $compile(template)($scope);
|
|
97
|
+
$scope.$digest();
|
|
98
|
+
spyOn($scope, "$digest").and.callThrough();
|
|
99
|
+
|
|
100
|
+
const mutationObserverCallback =
|
|
101
|
+
MutationObserver.calls.mostRecent().args[0];
|
|
102
|
+
const mutationRecord = {
|
|
103
|
+
target: element[0],
|
|
104
|
+
attributeName: "test-attribute",
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
element.attr("test-attribute", "newValue");
|
|
108
|
+
element[0].setAttribute("test-attribute", "newValue");
|
|
109
|
+
|
|
110
|
+
mutationObserverCallback([mutationRecord]);
|
|
111
|
+
expect($scope.$digest).toHaveBeenCalled();
|
|
112
|
+
});
|
|
92
113
|
});
|
|
@@ -86,11 +86,7 @@
|
|
|
86
86
|
<br />
|
|
87
87
|
|
|
88
88
|
{{ activeid }}
|
|
89
|
-
<fluent-tabs
|
|
90
|
-
ng-observe="activeid"
|
|
91
|
-
data-update="activeid"
|
|
92
|
-
activeid="entrees"
|
|
93
|
-
>
|
|
89
|
+
<fluent-tabs ng-observe="activeid" activeid="entrees">
|
|
94
90
|
<fluent-tab id="apps">Appetizers</fluent-tab>
|
|
95
91
|
<fluent-tab id="entrees">Entrees</fluent-tab>
|
|
96
92
|
<fluent-tab id="desserts">Desserts</fluent-tab>
|
|
@@ -173,13 +169,9 @@
|
|
|
173
169
|
</fluent-tab-panel>
|
|
174
170
|
</fluent-tabs>
|
|
175
171
|
|
|
176
|
-
{{
|
|
172
|
+
{{ value }}
|
|
177
173
|
|
|
178
|
-
<fluent-radio-group
|
|
179
|
-
ng-observe="value"
|
|
180
|
-
data-update="radio"
|
|
181
|
-
orientation="vertical"
|
|
182
|
-
>
|
|
174
|
+
<fluent-radio-group ng-observe="value" orientation="vertical">
|
|
183
175
|
<fluent-radio value="1">18-24</fluent-radio>
|
|
184
176
|
<fluent-radio value="2">25-33</fluent-radio>
|
|
185
177
|
<fluent-radio value="3">34-44</fluent-radio>
|
|
@@ -230,15 +230,13 @@ export class LocationHtml5Url extends Location {
|
|
|
230
230
|
*/
|
|
231
231
|
export class LocationHashbangUrl extends Location {
|
|
232
232
|
constructor(appBase: any, appBaseNoFile: any, hashPrefix: any);
|
|
233
|
-
appBase: any;
|
|
234
|
-
appBaseNoFile: any;
|
|
235
233
|
hashPrefix: any;
|
|
236
234
|
/**
|
|
237
235
|
* Parse given hashbang URL into properties
|
|
238
236
|
* @param {string} url Hashbang URL
|
|
239
237
|
*/
|
|
240
238
|
$$parse(url: string): void;
|
|
241
|
-
$$normalizeUrl(url: any):
|
|
239
|
+
$$normalizeUrl(url: any): string;
|
|
242
240
|
/**
|
|
243
241
|
* @param {string} url
|
|
244
242
|
* @returns {boolean}
|