Skip to content

Commit

Permalink
Fix tests by simplifying an import
Browse files Browse the repository at this point in the history
I think that JS event listeners aren't promise-aware, so there's a race condition in the test. It works fine in my browser though; rather than spending time debugging, I'm choosing to remove the promise. It might be worth looking at the resulting bundle sizes to make sure it doesn't slow it down too much.

Refs #1817, 593f930
  • Loading branch information
thewilkybarkid committed Aug 28, 2024
1 parent 593f930 commit 61f10c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
"@typescript-eslint/no-unused-expressions": "off"
}
},
{
"files": ["assets/**/*.ts"],
"rules": {
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }]
}
},
{
"files": ["integration/**/*.ts", "visual-regression/**/*.ts"],
"rules": {
Expand Down
8 changes: 2 additions & 6 deletions assets/single-use-form.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { disableButton, getLang } from './dom.js'
import { DefaultLocale, isSupportedLocale } from './locales/index.js'

const translateDep = import('./locales/index.js')
import { DefaultLocale, isSupportedLocale, translate } from './locales/index.js'

export class SingleUseForm extends HTMLElement {
static element = 'single-use-form' as const
Expand All @@ -12,7 +10,7 @@ export class SingleUseForm extends HTMLElement {
this.addEventListener('submit', this.onSubmit)
}

private onSubmit = async (event: SubmitEvent) => {
private onSubmit = (event: SubmitEvent) => {
const form = event.target
if (!(form instanceof HTMLFormElement)) {
return
Expand All @@ -21,8 +19,6 @@ export class SingleUseForm extends HTMLElement {
if (form.dataset['submitted'] === 'true') {
event.preventDefault()
} else {
const { translate } = await translateDep

const lang = getLang(this)
const locale = isSupportedLocale(lang) ? lang : DefaultLocale

Expand Down

0 comments on commit 61f10c9

Please sign in to comment.