HS E40: generator removes 7 E40 tests from skip-list; window.addEventListener handler (+1)

This commit is contained in:
2026-04-25 18:55:40 +00:00
parent ea1bdab82c
commit 8e4bdb7216
2 changed files with 79 additions and 19 deletions

View File

@@ -125,19 +125,9 @@ SKIP_TEST_NAMES = {
"can ignore when target doesn't exist",
"can ignore when target doesn\\'t exist",
"can handle an or after a from clause",
# upstream 'fetch' category — depend on per-test sinon stubs for 404 / thrown errors,
# or on real DocumentFragment semantics (`its childElementCount` after `as html`).
# Our generic test-runner mock returns a fixed 200 response, so these cases
# (non-2xx handling, error path, before-fetch event, real DOM fragment) can't be
# exercised here.
# upstream 'fetch' category — real DocumentFragment semantics (`its childElementCount`
# after `as html`) not exercisable with our DOM mock.
"can do a simple fetch w/ html",
"triggers an event just before fetching",
"can catch an error that occurs when using fetch",
"throws on non-2xx response by default",
"do not throw passes through 404 response",
"don't throw passes through 404 response",
"as response does not throw on 404",
"Response can be converted to JSON via as JSON",
}
@@ -963,6 +953,24 @@ def parse_dev_body(body, elements, var_names):
else:
pre_setups.append(('__hs_config__', op_expr))
continue
# window.addEventListener(EVT, (param) => { param.target.PROP = 'VAL'; })
wa = re.search(
r"window\.addEventListener\(\s*(['\"])([^'\"]+)\1\s*,\s*"
r"\((\w+)\)\s*=>\s*\{\s*\3\.target\.(\w+)\s*=\s*['\"]([^'\"]+)['\"]\s*;?\s*\}",
m.group(1),
)
if wa:
ev_name = wa.group(2)
prop = wa.group(4)
val = wa.group(5)
attr = 'class' if prop == 'className' else prop
sx = (f'(host-call (host-global "window") "addEventListener" "{ev_name}" '
f'(fn (_event) (dom-set-attr (host-get _event "target") "{attr}" "{val}")))')
if seen_html:
ops.append(sx)
else:
pre_setups.append(('__hs_config__', sx))
continue
# fall through
# evaluate(() => _hyperscript.config.X = ...) single-line variant.