HS: show multi-element + display retention (+2 tests)

Two fixes in `tests/hs-run-filtered.js`: (a) `mt` (matches-selector)
now splits comma-separated selector lists and matches if any clause
matches, so `qsa("#d1, #d2")` returns both elements. (b) `host-get` on
an `El` for `innerText` returns `textContent` (DOM-level alias) so
`when its innerText contains "foo"` predicates can see the mock's
stored text.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 06:30:17 +00:00
parent 92c1fc72a5
commit 98c957b3bf

View File

@@ -239,6 +239,10 @@ function parseHTMLFragments(html) {
function mt(e,s) { function mt(e,s) {
if(!e||!e.tagName)return false; if(!e||!e.tagName)return false;
s = s.trim(); s = s.trim();
// Comma-separated selector list — any clause matches
if (s.includes(',')) {
return s.split(',').some(part => mt(e, part.trim()));
}
// Strip pseudo-classes we handle at the fnd() level (nth-of-type, first/last-of-type) // Strip pseudo-classes we handle at the fnd() level (nth-of-type, first/last-of-type)
const pseudo = s.match(/^(.*?):(nth-of-type|first-of-type|last-of-type)(?:\((\d+)\))?$/); const pseudo = s.match(/^(.*?):(nth-of-type|first-of-type|last-of-type)(?:\((\d+)\))?$/);
const base = pseudo ? pseudo[1] : s; const base = pseudo ? pseudo[1] : s;
@@ -297,6 +301,8 @@ K.registerNative('host-get',a=>{
// compiled HS `x.length` / `x.size` works on scoped lists. // compiled HS `x.length` / `x.size` works on scoped lists.
if(a[0] && a[0]._type==='list' && (a[1]==='length' || a[1]==='size')) return a[0].items.length; if(a[0] && a[0]._type==='list' && (a[1]==='length' || a[1]==='size')) return a[0].items.length;
if(a[0] && a[0]._type==='dict' && a[1]==='size') return Object.keys(a[0]).filter(k=>k!=='_type').length; if(a[0] && a[0]._type==='dict' && a[1]==='size') return Object.keys(a[0]).filter(k=>k!=='_type').length;
// innerText is DOM-level alias for textContent (close enough for mock purposes)
if(a[0] instanceof El && a[1]==='innerText') return String(a[0].textContent||'');
let v=a[0][a[1]]; let v=a[0][a[1]];
if(v===undefined)return null; if(v===undefined)return null;
if((a[1]==='innerHTML'||a[1]==='textContent'||a[1]==='value'||a[1]==='className')&&typeof v!=='string')v=String(v!=null?v:''); if((a[1]==='innerHTML'||a[1]==='textContent'||a[1]==='value'||a[1]==='className')&&typeof v!=='string')v=String(v!=null?v:'');