Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use strict equals #1936

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Breakpoint/Breakpoint.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
xlg: size == "xlg",
max: size == "max",
};
$: if (size != undefined)
$: if (size !== undefined)
dispatch("change", { size, breakpointValue: breakpoints[size] });
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/ComposedModal/ComposedModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
if (selectorPrimaryFocus == null) return;
const node =
(element || innerModal)?.querySelector(selectorPrimaryFocus) || buttonRef;
if (node != null) node.focus();
if (node !== null) node.focus();
Copy link
Contributor

@brunnerh brunnerh Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line above already has some optional chaining, could be used here as well.

Suggested change
if (node !== null) node.focus();
node?.focus();

(Also, regarding the line above, || should not be abused, the correct operator would be ??)

}

let opened = false;
Expand Down
6 changes: 3 additions & 3 deletions src/ContextMenu/ContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
openDetail = e.target;
}

$: if (target != null) {
$: if (target !== null) {
if (Array.isArray(target)) {
target.forEach((node) => node?.addEventListener("contextmenu", openMenu));
} else {
Expand All @@ -94,7 +94,7 @@

onMount(() => {
return () => {
if (target != null) {
if (target !== null) {
if (Array.isArray(target)) {
target.forEach((node) =>
node?.removeEventListener("contextmenu", openMenu)
Expand Down Expand Up @@ -140,7 +140,7 @@

<svelte:window
on:contextmenu="{(e) => {
if (target != null) return;
if (target !== null) return;
if (level > 1) return;
if (!ref) return;
openMenu(e);
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/DataTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
$: $tableRows = rows;
$: sortedRows = [...$tableRows];
$: ascending = sortDirection === "ascending";
$: sorting = sortable && sortKey != null;
$: sorting = sortable && sortKey !== null;
$: sortingHeader = headers.find((header) => header.key === sortKey);
$: if (sorting) {
if (sortDirection === "none") {
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/ToolbarMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

let menuRef = null;

$: ctx.setOverflowVisible(menuRef != null);
$: ctx.setOverflowVisible(menuRef !== null);
$: if (menuRef) menuRef.style.top = "100%";
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/ImageLoader/ImageLoader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @type {(url?: string) => void}
*/
export const loadImage = (url) => {
if (image != null) image = null;
if (image !== null) image = null;
loaded = false;
error = false;
image = new Image();
Expand Down
2 changes: 1 addition & 1 deletion src/LocalStorage/LocalStorage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
onMount(() => {
const item = localStorage.getItem(key);

if (item != null) {
if (item !== null) {
try {
value = JSON.parse(item);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/NumberInput/NumberInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"Numeric input field with increment and decrement buttons";

function parse(raw) {
return raw != "" ? Number(raw) : null;
return raw !== "" ? Number(raw) : null;
}

function onInput({ target }) {
Expand Down
2 changes: 1 addition & 1 deletion src/TextInput/TextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

function parse(raw) {
if ($$restProps.type !== "number") return raw;
return raw != "" ? Number(raw) : null;
return raw !== "" ? Number(raw) : null;
}

/** @type {(e: Event) => void} */
Expand Down
2 changes: 1 addition & 1 deletion src/TreeView/TreeView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"li.bx--tree-node:not(.bx--tree-node--disabled)"
);

if (firstFocusableNode != null) {
if (firstFocusableNode !== null) {
firstFocusableNode.tabIndex = "0";
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/TreeView/TreeViewNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

let parentNode = node.parentNode;

while (parentNode != null && parentNode.getAttribute("role") !== "tree") {
while (parentNode !== null && parentNode.getAttribute("role") !== "tree") {
parentNode = parentNode.parentNode;
if (parentNode.tagName === "LI") depth++;
}
Expand Down
Loading