@veryfront/ext-parser-babel 0.1.1146 → 0.1.1147

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.
@@ -1 +1 @@
1
- {"version":3,"file":"inject-node-positions.d.ts","sourceRoot":"","sources":["../src/inject-node-positions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0EH,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA4CD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAsDrF"}
1
+ {"version":3,"file":"inject-node-positions.d.ts","sourceRoot":"","sources":["../src/inject-node-positions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0EH,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA8DD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CA0DrF"}
@@ -66,6 +66,24 @@ function getElementName(openingElement) {
66
66
  parts.unshift(current.name);
67
67
  return parts.length ? parts.join(".") : "MemberExpression";
68
68
  }
69
+ /**
70
+ * Only intrinsic host elements (lowercase tag names like `div`, `button`, or
71
+ * custom elements containing a hyphen) may receive `data-node-*` attributes.
72
+ *
73
+ * Component elements (`<Menu>`, `<Foo.Bar>`) receive those attributes as React
74
+ * *props*, not DOM attributes. Component libraries frequently forward unknown
75
+ * props onto whatever they render — and if that is a `React.Fragment` (as with
76
+ * Headless UI's `<Menu>`/`<Listbox>`), passing props throws:
77
+ * "Passing props on 'Fragment'!"
78
+ * Stamping components is also pointless for Studio Navigator, since the mapped
79
+ * DOM ultimately comes from the host elements the component renders.
80
+ */
81
+ function isHostElement(openingElement) {
82
+ const { name } = openingElement;
83
+ if (!t.isJSXIdentifier(name))
84
+ return false; // member / namespaced ⇒ component
85
+ return /^[a-z]/.test(name.name) || name.name.includes("-");
86
+ }
69
87
  function isFragment(openingElement) {
70
88
  const { name } = openingElement;
71
89
  if (t.isJSXMemberExpression(name)) {
@@ -107,6 +125,11 @@ export function injectNodePositions(source, options) {
107
125
  return;
108
126
  if (isFragment(openingElement))
109
127
  return;
128
+ // Never stamp component elements — the attributes would become React
129
+ // props and break libraries that forward props onto a Fragment
130
+ // (Headless UI, etc.). Only intrinsic DOM elements get positions.
131
+ if (!isHostElement(openingElement))
132
+ return;
110
133
  if (hasPositionAttribute(openingElement.attributes))
111
134
  return;
112
135
  const loc = openingElement.loc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veryfront/ext-parser-babel",
3
- "version": "0.1.1146",
3
+ "version": "0.1.1147",
4
4
  "description": "Veryfront first-party extension package for ext-parser-babel",
5
5
  "keywords": [
6
6
  "veryfront",
@@ -48,7 +48,7 @@
48
48
  "@babel/types": "7.29.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "veryfront": "^0.1.1146"
51
+ "veryfront": "^0.1.1147"
52
52
  },
53
53
  "type": "module",
54
54
  "types": "./esm/index.d.ts",