Skip to content

Commit edfdbe1

Browse files
authored
chore(Script): downgrade script syntax (#5578)
* refactor: update ??= to ||= * refactor: 移除 ??= 表达式 * refactor: 移除 ?. 表达式 * refactor: 精简代码 * refactor: 重构代码
1 parent ba03fac commit edfdbe1

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export function init(id, invoke, options) {
1313
return el.classList.contains('disabled');
1414
},
1515
hideCallback: () => {
16-
invoke?.invokeMethodAsync(options.triggerHideCallback);
16+
if (invoke) {
17+
invoke.invokeMethodAsync(options.triggerHideCallback);
18+
}
1719
}
1820
});
1921
const dateTimePicker = {

src/BootstrapBlazor/Components/Table/Table.razor.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,22 @@ const setExcelKeyboardListener = table => {
425425
}
426426
}
427427
else if (keyCode === KeyCodes.UP_ARROW) {
428-
cells = tr.previousElementSibling?.children;
429-
while (index < cells.length) {
430-
if (activeCell(cells, index)) {
431-
break;
428+
cells = tr.previousElementSibling && tr.previousElementSibling.children;
429+
if (cells) {
430+
while (index < cells.length) {
431+
if (activeCell(cells, index)) {
432+
break;
433+
}
432434
}
433435
}
434436
}
435437
else if (keyCode === KeyCodes.DOWN_ARROW) {
436-
cells = tr.nextElementSibling?.children;
437-
while (index < cells.length) {
438-
if (activeCell(cells, index)) {
439-
break;
438+
cells = tr.nextElementSibling && tr.nextElementSibling.children;
439+
if (cells) {
440+
while (index < cells.length) {
441+
if (activeCell(cells, index)) {
442+
break;
443+
}
440444
}
441445
}
442446
}

src/BootstrapBlazor/Components/Typed/Typed.razor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Typed from '../../lib/typedjs/typed.module.js'
33

44
const getOptions = (text, invoke, options, callbacks) => {
5-
options ??= {};
5+
options ||= {};
66

77
if (text) {
88
options.strings = [text];

src/BootstrapBlazor/wwwroot/modules/fullscreen.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
export async function toggle(options) {
44
let el = null;
5-
if (options?.id) {
5+
options ||= {};
6+
if (options.id) {
67
el = document.getElementById(options.id);
78
}
8-
else if (options?.element && isElement(options.element)) {
9+
else if (isElement(options.element)) {
910
el = options.element;
1011
}
1112
else {

src/BootstrapBlazor/wwwroot/modules/utility.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ const deepMerge = (obj1, obj2, skipNull = true) => {
809809
}
810810

811811
export function registerBootstrapBlazorModule(name, identifier, callback) {
812-
window.BootstrapBlazor ??= {};
813-
window.BootstrapBlazor[name] ??= {
812+
window.BootstrapBlazor ||= {};
813+
window.BootstrapBlazor[name] ||= {
814814
_init: false,
815815
_items: [],
816816
register: function (id, cb) {

0 commit comments

Comments
 (0)