Skip to content

Commit 7f55475

Browse files
author
Anatoly Ostrovsky
committed
Test fixes and refactor for let
1 parent 55cc734 commit 7f55475

File tree

27 files changed

+899
-704
lines changed

27 files changed

+899
-704
lines changed

@types/core/sce/sce.d.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ export class SceProvider {
1010
* Enables/disables SCE and returns the current value.
1111
*/
1212
enabled: (value?: boolean | undefined, ...args: any[]) => boolean;
13-
$get: (
14-
| string
15-
| (($parse: any, $sceDelegate: any, $exceptionHandler: any) => any)
16-
)[];
13+
$get: (string | (($parse: any, $sceDelegate: any) => any))[];
1714
}
1815
export namespace SCE_CONTEXTS {
1916
let HTML: string;
@@ -236,7 +233,7 @@ export class SceDelegateProvider {
236233
$get: (
237234
| string
238235
| ((
239-
$injector: any,
236+
$injector: import("../../core/di/internal-injector.js").InjectorService,
240237
$$sanitizeUri: any,
241238
$exceptionHandler: ErrorHandler,
242239
) => {

@types/router/params/param.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ export class Param {
4949
validates(value: any): boolean;
5050
toString(): string;
5151
}
52-
export var DefType: any;
52+
export let DefType: any;

src/animations/animate-css.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ export function AnimateCssProvider() {
267267
// all of the animation functions should create
268268
// a copy of the options data, however, if a
269269
// parent service has already created a copy then
270+
let delayStyle;
270271
// we should stick to using that
271272
let options = initialOptions || {};
272273
if (!options.$$prepared) {
@@ -479,13 +480,12 @@ export function AnimateCssProvider() {
479480
return closeAndReturnNoopAnimator();
480481
}
481482

482-
var activeClasses = pendClasses(
483+
let activeClasses = pendClasses(
483484
preparationClasses,
484485
ACTIVE_CLASS_SUFFIX,
485486
);
486487

487488
if (options.delay != null) {
488-
var delayStyle;
489489
if (typeof options.delay !== "boolean") {
490490
delayStyle = parseFloat(options.delay);
491491
// number in options.delay means we have to recalculate the delay for the closing timeout

src/animations/animate-runner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
export function AnimateAsyncRunFactoryProvider() {
22
this.$get = [
33
function () {
4-
var waitQueue = [];
4+
let waitQueue = [];
55

66
function waitForTick(fn) {
77
waitQueue.push(fn);
88
if (waitQueue.length > 1) return;
99
window.requestAnimationFrame(function () {
10-
for (var i = 0; i < waitQueue.length; i++) {
10+
for (let i = 0; i < waitQueue.length; i++) {
1111
waitQueue[i]();
1212
}
1313
waitQueue = [];
1414
});
1515
}
1616

1717
return function () {
18-
var passed = false;
18+
let passed = false;
1919
waitForTick(function () {
2020
passed = true;
2121
});

src/animations/shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export function resolveElementClasses(existing, toAdd, toRemove) {
256256
};
257257

258258
Object.entries(flags).forEach(([klass, val]) => {
259-
var prop, allow;
259+
let prop, allow;
260260
if (val === ADD_CLASS) {
261261
prop = "addClass";
262262
allow = !existing[klass] || existing[klass + REMOVE_CLASS_SUFFIX];

src/core/compile/compile.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ export class CompileProvider {
14671467
// RECURSION
14681468
// We only pass the isolate scope, if the isolate directive has a template,
14691469
// otherwise the child elements do not belong to the isolate directive.
1470-
var scopeToChild = scope;
1470+
let scopeToChild = scope;
14711471
if (
14721472
newIsolateScopeDirective &&
14731473
(newIsolateScopeDirective.template ||
@@ -2472,6 +2472,8 @@ export class CompileProvider {
24722472
.catch((error) => {
24732473
if (isError(error)) {
24742474
$exceptionHandler(error);
2475+
} else {
2476+
$exceptionHandler(new Error(error));
24752477
}
24762478
});
24772479

@@ -2579,11 +2581,12 @@ export class CompileProvider {
25792581
type = (type || "html").toLowerCase();
25802582
switch (type) {
25812583
case "svg":
2582-
case "math":
2583-
/** @type {HTMLDivElement} */
2584-
var wrapper = document.createElement("div");
2584+
case "math": {
2585+
const wrapper =
2586+
/** @type {HTMLDivElement} */ document.createElement("div");
25852587
wrapper.innerHTML = `<${type}>${template}</${type}>`;
25862588
return wrapper.childNodes[0].childNodes;
2589+
}
25872590
default:
25882591
return template;
25892592
}
@@ -2659,29 +2662,30 @@ export class CompileProvider {
26592662
// If you want to programmatically set explicitly trusted unsafe URLs, you should use
26602663
// `$sce.trustAsHtml` on the whole `img` tag and inject it into the DOM using the
26612664
// `ng-bind-html` directive.
2662-
var result = "";
2665+
let result = "";
26632666

26642667
// first check if there are spaces because it's not the same pattern
2665-
var trimmedSrcset = trim(value);
2668+
const trimmedSrcset = trim(value);
26662669
// ( 999x ,| 999w ,| ,|, )
2667-
var srcPattern = /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/;
2668-
var pattern = /\s/.test(trimmedSrcset) ? srcPattern : /(,)/;
2670+
const srcPattern = /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/;
2671+
const pattern = /\s/.test(trimmedSrcset) ? srcPattern : /(,)/;
26692672

26702673
// split srcset into tuple of uri and descriptor except for the last item
2671-
var rawUris = trimmedSrcset.split(pattern);
2674+
const rawUris = trimmedSrcset.split(pattern);
26722675

26732676
// for each tuples
2674-
var nbrUrisWith2parts = Math.floor(rawUris.length / 2);
2675-
for (var i = 0; i < nbrUrisWith2parts; i++) {
2676-
var innerIdx = i * 2;
2677+
const nbrUrisWith2parts = Math.floor(rawUris.length / 2);
2678+
let i;
2679+
for (i = 0; i < nbrUrisWith2parts; i++) {
2680+
const innerIdx = i * 2;
26772681
// sanitize the uri
26782682
result += $sce.getTrustedMediaUrl(trim(rawUris[innerIdx]));
26792683
// add the descriptor
26802684
result += " " + trim(rawUris[innerIdx + 1]);
26812685
}
26822686

26832687
// split the last item into uri and descriptor
2684-
var lastTuple = trim(rawUris[i * 2]).split(/\s/);
2688+
const lastTuple = trim(rawUris[i * 2]).split(/\s/);
26852689

26862690
// sanitize the last uri
26872691
result += $sce.getTrustedMediaUrl(trim(lastTuple[0]));
@@ -2985,7 +2989,7 @@ export class CompileProvider {
29852989
removeWatchCollection.push(removeWatch);
29862990
break;
29872991

2988-
case "=":
2992+
case "=": {
29892993
if (!hasOwn(attrs, attrName)) {
29902994
if (optional) {
29912995
break;
@@ -2998,7 +3002,6 @@ export class CompileProvider {
29983002
}
29993003

30003004
parentGet = $parse(attrs[attrName]);
3001-
var complexExpression = !!parentGet.inputs;
30023005
if (parentGet.literal) {
30033006
compare = equals;
30043007
} else {
@@ -3023,7 +3026,7 @@ export class CompileProvider {
30233026
lastValue = destination.$target[scopeName] = parentGet(
30243027
scope.$target,
30253028
);
3026-
var parentValueWatch = function parentValueWatch(
3029+
const parentValueWatch = function parentValueWatch(
30273030
parentValue,
30283031
) {
30293032
if (!compare(parentValue, destination[scopeName])) {
@@ -3055,7 +3058,7 @@ export class CompileProvider {
30553058
scope.$watch(
30563059
expr,
30573060
(val) => {
3058-
var res = $parse(attrs[attrName], parentValueWatch);
3061+
const res = $parse(attrs[attrName], parentValueWatch);
30593062
if (val) {
30603063
if (parentGet.literal) {
30613064
scope.$target[attrName] = val;
@@ -3081,7 +3084,7 @@ export class CompileProvider {
30813084
return;
30823085
}
30833086
if (
3084-
(complexExpression && !parentGet.literal) ||
3087+
(!!parentGet.inputs && !parentGet.literal) ||
30853088
(isUndefined(attrs[attrName]) && isDefined(val))
30863089
) {
30873090
destination.$target[attrName] = lastValue;
@@ -3113,6 +3116,7 @@ export class CompileProvider {
31133116
}
31143117
removeWatchCollection.push(removeWatch);
31153118
break;
3119+
}
31163120

31173121
case "<":
31183122
if (!hasOwn(attrs, attrName)) {

0 commit comments

Comments
 (0)