Merge branch 'hs-e40-fetch' into loops/hs
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 16s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 16s
This commit is contained in:
@@ -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",
|
||||
}
|
||||
|
||||
|
||||
@@ -973,6 +963,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.
|
||||
|
||||
Reference in New Issue
Block a user