@ibealec/create-zed-bridge 1.0.5 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibealec/create-zed-bridge",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Setup script for @zed-controller/react-bridge and LocatorJS integration",
5
5
  "type": "module",
6
6
  "bin": {
@@ -200,7 +200,7 @@ function captureContext(element) {
200
200
  selectedText: getSelectedText(),
201
201
  selectedElement: {
202
202
  tagName: element.tagName.toLowerCase(),
203
- className: element.className,
203
+ className: getClassNameString(element),
204
204
  id: element.id || void 0,
205
205
  innerText: truncateText(element.innerText, 200)
206
206
  },
@@ -222,12 +222,22 @@ function getSelectedText() {
222
222
  return void 0;
223
223
  }
224
224
  function truncateText(text, maxLength) {
225
+ if (!text) return "";
225
226
  const cleaned = text.replace(/\s+/g, " ").trim();
226
227
  if (cleaned.length <= maxLength) {
227
228
  return cleaned;
228
229
  }
229
230
  return cleaned.slice(0, maxLength) + "...";
230
231
  }
232
+ function getClassNameString(element) {
233
+ if (typeof element.className === "string") {
234
+ return element.className;
235
+ }
236
+ if (element.className && typeof element.className.baseVal === "string") {
237
+ return element.className.baseVal;
238
+ }
239
+ return "";
240
+ }
231
241
  function getSourceFile(element) {
232
242
  let current = element;
233
243
  while (current) {
@@ -330,10 +340,13 @@ function getDomPath(element) {
330
340
  let selector = current.tagName.toLowerCase();
331
341
  if (current.id) {
332
342
  selector += `#${current.id}`;
333
- } else if (current.className) {
334
- const classes = current.className.split(/\s+/).filter((c) => c && !c.startsWith("__")).slice(0, 2).join(".");
335
- if (classes) {
336
- selector += `.${classes}`;
343
+ } else {
344
+ const classNameStr = getClassNameString(current);
345
+ if (classNameStr) {
346
+ const classes = classNameStr.split(/\s+/).filter((c) => c && !c.startsWith("__")).slice(0, 2).join(".");
347
+ if (classes) {
348
+ selector += `.${classes}`;
349
+ }
337
350
  }
338
351
  }
339
352
  path.unshift(selector);
@@ -510,10 +523,14 @@ function createHighlightOverlay() {
510
523
  let labelText = element.tagName.toLowerCase();
511
524
  if (element.id) {
512
525
  labelText += `#${element.id}`;
513
- } else if (element.className) {
514
- const firstClass = element.className.split(/\s+/)[0];
515
- if (firstClass && !firstClass.startsWith("__")) {
516
- labelText += `.${firstClass}`;
526
+ } else {
527
+ const className = element.className;
528
+ const classNameStr = typeof className === "string" ? className : className?.baseVal || "";
529
+ if (classNameStr) {
530
+ const firstClass = classNameStr.split(/\s+/)[0];
531
+ if (firstClass && !firstClass.startsWith("__")) {
532
+ labelText += `.${firstClass}`;
533
+ }
517
534
  }
518
535
  }
519
536
  label.textContent = labelText;