HS: DOM ref-eq + compound selector + DOM tree fixes

- hs-id= uses JS === for DOM elements (hs-ref-eq), = for scalars
- != operator now uses hs-id= for structural correctness
- compound tag[attr=val] selector matching in test runner
- dom-query-all replaces host-call querySelectorAll
- DOM tree structure corrected in 4 generated tests (elements were
  appended to wrong parents)
This commit is contained in:
2026-04-26 17:49:51 +00:00
parent f2993f0582
commit a48110417b
9 changed files with 95 additions and 61 deletions

View File

@@ -210,11 +210,18 @@ def parse_html(html):
# button HTML in `properly processes hyperscript X` tests). HTMLParser handles
# backslashes in attribute values as literal characters, so we leave them.
# HTML5 void elements — never have children, auto-pop from stack immediately.
VOID_TAGS = {'area','base','br','col','embed','hr','img','input','link',
'meta','param','source','track','wbr'}
elements = []
stack = []
class Parser(HTMLParser):
def handle_starttag(self, tag, attrs):
# Pop any void elements left on the stack (they have no close tag).
while stack and stack[-1]['tag'] in VOID_TAGS:
stack.pop()
el = {
'tag': tag, 'id': None, 'classes': [], 'hs': None,
'attrs': {}, 'inner': '', 'depth': len(stack),
@@ -244,6 +251,9 @@ def parse_html(html):
elements.append(el)
def handle_endtag(self, tag):
# Pop void elements first (they don't have close tags but may linger).
while stack and stack[-1]['tag'] in VOID_TAGS:
stack.pop()
if stack and stack[-1]['tag'] == tag:
stack.pop()