generator: translate evaluate(getElementById/querySelector).METHOD() calls
Upstream body helpers often call element methods directly — showModal, close, focus, blur, reset, remove. Emit dom-dispatch or host-call ops so tests that rely on these pre-click state changes work. Net: dialog 9→12 (100%).
This commit is contained in:
@@ -2833,6 +2833,7 @@
|
||||
(dom-append _el-d _el-p)
|
||||
(dom-append _el-d _el-close)
|
||||
(hs-activate! _el-close)
|
||||
(host-call (dom-query-by-id "d") "showModal")
|
||||
(assert (dom-has-attr? (dom-query-by-id "d") "open"))
|
||||
(dom-dispatch (dom-query-by-id "close") "click" nil)
|
||||
(assert (not (dom-has-attr? (dom-query-by-id "d") "open")))
|
||||
@@ -2863,6 +2864,7 @@
|
||||
(dom-append _el-d _el-p)
|
||||
(dom-append _el-d _el-close)
|
||||
(hs-activate! _el-close)
|
||||
(host-call (dom-query-by-id "d") "showModal")
|
||||
(assert (dom-has-attr? (dom-query-by-id "d") "open"))
|
||||
(dom-dispatch (dom-query-by-id "close") "click" nil)
|
||||
(assert (not (dom-has-attr? (dom-query-by-id "d") "open")))
|
||||
@@ -2950,6 +2952,7 @@
|
||||
(dom-append _el-d _el-p)
|
||||
(dom-append _el-d _el-button)
|
||||
(hs-activate! _el-button)
|
||||
(host-call (dom-query-by-id "d") "showModal")
|
||||
(assert (dom-has-attr? (dom-query-by-id "d") "open"))
|
||||
(dom-dispatch _el-button "click" nil)
|
||||
(assert (dom-has-attr? (dom-query-by-id "d") "open"))
|
||||
|
||||
@@ -954,6 +954,38 @@ def parse_dev_body(body, elements, var_names):
|
||||
ops.append(f'(dom-dispatch {target} "{m.group(4)}" nil)')
|
||||
continue
|
||||
|
||||
# evaluate(() => document.getElementById(ID).METHOD()) — generic
|
||||
# method dispatch (showModal, close, click, focus, blur, reset…).
|
||||
m = re.match(
|
||||
r"evaluate\(\s*\(\)\s*=>\s*document\.(?:getElementById|querySelector)\("
|
||||
r"\s*(['\"])([^'\"]+)\1\s*\)"
|
||||
r"\.(click|showModal|close|focus|blur|reset|remove)\(\)\s*\)\s*$",
|
||||
stmt_na, re.DOTALL,
|
||||
)
|
||||
if m and seen_html:
|
||||
sel = m.group(2)
|
||||
# getElementById wants bare id; querySelector wants #id or .cls
|
||||
if sel and not sel.startswith(('#', '.', '[')):
|
||||
sel = '#' + sel
|
||||
sel = re.sub(r'^#work-area\s+', '', sel)
|
||||
target = selector_to_sx(sel, elements, var_names)
|
||||
method = m.group(3)
|
||||
if method == 'click':
|
||||
ops.append(f'(dom-dispatch {target} "click" nil)')
|
||||
elif method == 'showModal':
|
||||
ops.append(f'(host-call {target} "showModal")')
|
||||
elif method == 'close':
|
||||
ops.append(f'(host-call {target} "close")')
|
||||
elif method == 'focus':
|
||||
ops.append(f'(dom-focus {target})')
|
||||
elif method == 'blur':
|
||||
ops.append(f'(host-call {target} "blur")')
|
||||
elif method == 'reset':
|
||||
ops.append(f'(host-call {target} "reset")')
|
||||
elif method == 'remove':
|
||||
ops.append(f'(host-call {target} "remove")')
|
||||
continue
|
||||
|
||||
if not seen_html:
|
||||
continue
|
||||
if add_action(stmt_na):
|
||||
|
||||
Reference in New Issue
Block a user