Skip to content

Commit 1df256b

Browse files
committed
handle namespaced elements in xpath build step
1 parent 9f54bcf commit 1df256b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/a11y/utils.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,18 @@ export async function buildBackendIdMaps(
222222
const tag = lc(String(child.nodeName));
223223
const key = `${child.nodeType}:${tag}`;
224224
const idx = (ctr[key] = (ctr[key] ?? 0) + 1);
225-
segs.push(
226-
child.nodeType === 3
227-
? `text()[${idx}]`
228-
: child.nodeType === 8
229-
? `comment()[${idx}]`
225+
if (child.nodeType === 3) {
226+
segs.push(`text()[${idx}]`);
227+
} else if (child.nodeType === 8) {
228+
segs.push(`comment()[${idx}]`);
229+
} else {
230+
// Element node: if qualified (e.g. "as:ajaxinclude"), switch to name()='as:ajaxinclude'
231+
segs.push(
232+
tag.includes(":")
233+
? `*[name()='${tag}'][${idx}]`
230234
: `${tag}[${idx}]`,
231-
);
235+
);
236+
}
232237
}
233238
// push R→L so traversal remains L→R
234239
for (let i = kids.length - 1; i >= 0; i--) {

0 commit comments

Comments
 (0)