Skip to content

Commit 29a4e6b

Browse files
committed
Format improvements
1 parent ac12446 commit 29a4e6b

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

src/animations/animate-swap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export function ngAnimateSwapDirective($animate) {
1010
terminal: true,
1111
priority: 550, // We use 550 here to ensure that the directive is caught before others,
1212
// but after `ngIf` (at priority 600).
13-
link(scope, $element, attrs, ctrl, $transclude) {
13+
link(scope, $element, attrs, _ctrl, $transclude) {
1414
let previousElement;
1515
let previousScope;
16-
scope.$watch(attrs["ngAnimateSwap"] || attrs["for"], (value) => {
16+
scope.$watch(attrs.ngAnimateSwap || attrs.for, (value) => {
1717
if (previousElement) {
1818
$animate.leave(previousElement);
1919
}

src/directive/events/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const ngEventDirectives = {};
1919
$t.$exceptionHandler,
2020

2121
/**
22-
* @param {import("../../core/parse/interface.ts").ParseService} $parse
22+
* @param {ng.ParseService} $parse
2323
* @param {ng.ExceptionHandlerService} $exceptionHandler
2424
* @returns
2525
*/

src/directive/http/http.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ export function createHttpDirective(method, attrName) {
227227
return {
228228
restrict: "A",
229229
link(scope, element, attrs) {
230-
const eventName = attrs["trigger"] || getEventNameForElement(element);
230+
const eventName = attrs.trigger || getEventNameForElement(element);
231231
const tag = element.tagName.toLowerCase();
232232

233-
if (isDefined(attrs["latch"])) {
233+
if (isDefined(attrs.latch)) {
234234
attrs.$observe(
235235
"latch",
236236
callBackAfterFirst(() =>
@@ -246,79 +246,79 @@ export function createHttpDirective(method, attrName) {
246246
element.dispatchEvent(new Event(eventName));
247247
intervalId = setInterval(
248248
() => element.dispatchEvent(new Event(eventName)),
249-
parseInt(attrs["interval"]) || 1000,
249+
parseInt(attrs.interval) || 1000,
250250
);
251251
}
252252

253253
element.addEventListener(eventName, async (event) => {
254254
if (/** @type {HTMLButtonElement} */ (element).disabled) return;
255255
if (tag === "form") event.preventDefault();
256-
const swap = attrs["swap"] || "innerHTML";
256+
const swap = attrs.swap || "innerHTML";
257257
const url = attrs[attrName];
258258
if (!url) {
259259
$log.warn(`${attrName}: no URL specified`);
260260
return;
261261
}
262262

263263
const handler = (res) => {
264-
if (isDefined(attrs["loading"])) {
264+
if (isDefined(attrs.loading)) {
265265
attrs.$set("loading", false);
266266
}
267267

268-
if (isDefined(attrs["loadingClass"])) {
269-
attrs.$removeClass(attrs["loadingClass"]);
268+
if (isDefined(attrs.loadingClass)) {
269+
attrs.$removeClass(attrs.loadingClass);
270270
}
271271

272272
const html = res.data;
273273
if (200 <= res.status && res.status <= 299) {
274-
if (isDefined(attrs["success"])) {
275-
$parse(attrs["success"])(scope, { $res: html });
274+
if (isDefined(attrs.success)) {
275+
$parse(attrs.success)(scope, { $res: html });
276276
}
277277

278-
if (isDefined(attrs["stateSuccess"])) {
279-
$state.go(attrs["stateSuccess"]);
278+
if (isDefined(attrs.stateSuccess)) {
279+
$state.go(attrs.stateSuccess);
280280
}
281281
} else if (400 <= res.status && res.status <= 599) {
282-
if (isDefined(attrs["error"])) {
283-
$parse(attrs["error"])(scope, { $res: html });
282+
if (isDefined(attrs.error)) {
283+
$parse(attrs.error)(scope, { $res: html });
284284
}
285285

286-
if (isDefined(attrs["stateError"])) {
287-
$state.go(attrs["stateError"]);
286+
if (isDefined(attrs.stateError)) {
287+
$state.go(attrs.stateError);
288288
}
289289
}
290290

291291
// simplified call (no long parameter list)
292292
handleSwapResponse(html, swap, scope, attrs, element);
293293
};
294294

295-
if (isDefined(attrs["delay"])) {
296-
await wait(parseInt(attrs["delay"]) | 0);
295+
if (isDefined(attrs.delay)) {
296+
await wait(parseInt(attrs.delay) | 0);
297297
}
298298

299299
if (throttled) return;
300300

301-
if (isDefined(attrs["throttle"])) {
301+
if (isDefined(attrs.throttle)) {
302302
throttled = true;
303303
attrs.$set("throttled", true);
304304
setTimeout(() => {
305305
attrs.$set("throttled", false);
306306
throttled = false;
307-
}, parseInt(attrs["throttle"]));
307+
}, parseInt(attrs.throttle));
308308
}
309309

310310
if (isDefined(attrs["loading"])) {
311311
attrs.$set("loading", true);
312312
}
313313

314314
if (isDefined(attrs["loadingClass"])) {
315-
attrs.$addClass(attrs["loadingClass"]);
315+
attrs.$addClass(attrs.loadingClass);
316316
}
317317

318318
if (method === "post" || method === "put") {
319319
let data;
320320
const config = {};
321-
if (attrs["enctype"]) {
321+
if (attrs.enctype) {
322322
config.headers = {
323323
"Content-Type": attrs["enctype"],
324324
};
@@ -331,7 +331,7 @@ export function createHttpDirective(method, attrName) {
331331
if (method === "get" && attrs.ngSse) {
332332
const sseUrl = url;
333333
const config = {
334-
withCredentials: attrs["withCredentials"] === "true",
334+
withCredentials: attrs.withCredentials === "true",
335335
transformMessage: (data) => {
336336
try {
337337
return JSON.parse(data);
@@ -341,9 +341,9 @@ export function createHttpDirective(method, attrName) {
341341
},
342342
onOpen: () => {
343343
$log.info(`${attrName}: SSE connection opened to ${sseUrl}`);
344-
if (isDefined(attrs["loading"])) attrs.$set("loading", false);
345-
if (isDefined(attrs["loadingClass"]))
346-
attrs.$removeClass(attrs["loadingClass"]);
344+
if (isDefined(attrs.loading)) attrs.$set("loading", false);
345+
if (isDefined(attrs.loadingClass))
346+
attrs.$removeClass(attrs.loadingClass);
347347
},
348348
onMessage: (data) => {
349349
const res = { status: 200, data };

0 commit comments

Comments
 (0)