vite-plugin-vue-testid 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +30 -11
- package/package.json +1 -1
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC,CAAA;CACzD;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB;IAClB,SAAS,EAAE,WAAW,CAAA;IACtB,iBAAiB;IACjB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,oBAAoB;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC,CAAA;CACzD;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB;IAClB,SAAS,EAAE,WAAW,CAAA;IACtB,iBAAiB;IACjB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,oBAAoB;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAA;AAukB7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAE,cAAmB,GAAG,MAAM,IAAI,CAwFrE;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,wBAAkB,CAAA;AAMtD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,cAAmB,GAAG,IAAI,CAgCtE"}
|
package/dist/runtime.js
CHANGED
|
@@ -284,8 +284,9 @@ function injectMenuItems(attrName, root = document, pc) {
|
|
|
284
284
|
{ selector: sel(pc, "menu-item-group"), textSelector: sel(pc, "menu-item-group-title"), prefix: "a-menu-item-group-" }
|
|
285
285
|
];
|
|
286
286
|
for (const rule of itemRules) {
|
|
287
|
-
const
|
|
288
|
-
items.
|
|
287
|
+
const descendants = Array.from(root.querySelectorAll(rule.selector));
|
|
288
|
+
const items = root instanceof HTMLElement && root.matches(rule.selector) ? [root, ...descendants] : descendants;
|
|
289
|
+
for (const item of items) {
|
|
289
290
|
const el = item;
|
|
290
291
|
if (el.hasAttribute(attrName)) return;
|
|
291
292
|
const id = el.getAttribute("id");
|
|
@@ -298,7 +299,7 @@ function injectMenuItems(attrName, root = document, pc) {
|
|
|
298
299
|
if (text) {
|
|
299
300
|
el.setAttribute(attrName, rule.prefix + text);
|
|
300
301
|
}
|
|
301
|
-
}
|
|
302
|
+
}
|
|
302
303
|
}
|
|
303
304
|
}
|
|
304
305
|
var _observedContainers = /* @__PURE__ */ new WeakSet();
|
|
@@ -307,18 +308,29 @@ function getTriggerTestId(trigger, attrName) {
|
|
|
307
308
|
return trigger.getAttribute(attrName) || trigger.getAttribute("id") || "unknown";
|
|
308
309
|
}
|
|
309
310
|
function findActiveTrigger(attrName, pc) {
|
|
311
|
+
const resolveInContainer = (el) => {
|
|
312
|
+
if (el.hasAttribute(attrName)) return el;
|
|
313
|
+
const inner = el.querySelector(`[${attrName}]`);
|
|
314
|
+
if (inner) return inner;
|
|
315
|
+
return null;
|
|
316
|
+
};
|
|
310
317
|
const focused = document.querySelector(sel(pc, "picker-focused"));
|
|
311
318
|
if (focused) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if (inner) return inner;
|
|
319
|
+
const found = resolveInContainer(focused);
|
|
320
|
+
if (found) return found;
|
|
315
321
|
const input = focused.querySelector("input[id]");
|
|
316
322
|
if (input) return input;
|
|
317
323
|
}
|
|
318
324
|
const selectOpen = document.querySelector(sel(pc, "select-open"));
|
|
319
|
-
if (selectOpen
|
|
325
|
+
if (selectOpen) {
|
|
326
|
+
const found = resolveInContainer(selectOpen);
|
|
327
|
+
if (found) return found;
|
|
328
|
+
}
|
|
320
329
|
const cascader = document.querySelector(sel(pc, "cascader-picker-focused"));
|
|
321
|
-
if (cascader
|
|
330
|
+
if (cascader) {
|
|
331
|
+
const found = resolveInContainer(cascader);
|
|
332
|
+
if (found) return found;
|
|
333
|
+
}
|
|
322
334
|
const expanded = document.querySelector(
|
|
323
335
|
`[${attrName}][aria-expanded="true"]`
|
|
324
336
|
);
|
|
@@ -401,9 +413,16 @@ function setupAntTestIds(opts = {}) {
|
|
|
401
413
|
if (container.hasAttribute(attrName)) continue;
|
|
402
414
|
if (strategy) {
|
|
403
415
|
queueMicrotask(() => {
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
416
|
+
const runPanelInjection = (retriesLeft) => {
|
|
417
|
+
const trigger = findActiveTrigger(attrName, pc);
|
|
418
|
+
const triggerTestId = getTriggerTestId(trigger, attrName);
|
|
419
|
+
if (triggerTestId === "unknown" && retriesLeft > 0) {
|
|
420
|
+
requestAnimationFrame(() => runPanelInjection(retriesLeft - 1));
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
strategy({ container, trigger, triggerTestId, attrName });
|
|
424
|
+
};
|
|
425
|
+
runPanelInjection(3);
|
|
407
426
|
});
|
|
408
427
|
}
|
|
409
428
|
}
|