@torpor/view 0.0.8 → 0.0.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @torpor/view
2
2
 
3
+ ## 0.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 3cf6de6: Fix: use namespace when creating svg fragments
8
+
9
+ ## 0.0.9
10
+
11
+ ### Patch Changes
12
+
13
+ - 47c5277: Chore: update dependencies
14
+
3
15
  ## 0.0.8
4
16
 
5
17
  ### Patch Changes
package/dist/compile.cjs CHANGED
@@ -119,7 +119,10 @@ function buildNodeFragmentText(node, status, fragments, currentFragment) {
119
119
  break;
120
120
  }
121
121
  case "element": {
122
+ let ns = node.tagName === "svg";
123
+ if (ns) status.ns = true;
122
124
  buildElementFragmentText(node, status, fragments, currentFragment);
125
+ if (ns) status.ns = false;
123
126
  break;
124
127
  }
125
128
  case "text": {
@@ -136,7 +139,7 @@ function buildNodeFragmentText(node, status, fragments, currentFragment) {
136
139
  }
137
140
  }
138
141
  function buildRootFragmentText(node, status, fragments) {
139
- node.fragment = { number: fragments.length, text: "", events: [], animations: [] };
142
+ node.fragment = { number: fragments.length, text: "", ns: status.ns, events: [], animations: [] };
140
143
  fragments.push(node.fragment);
141
144
  for (let child of node.children) {
142
145
  buildNodeFragmentText(child, status, fragments, node.fragment);
@@ -157,7 +160,13 @@ function buildControlFragmentText(node, status, fragments, currentFragment) {
157
160
  break;
158
161
  }
159
162
  default: {
160
- node.fragment = { number: fragments.length, text: "", events: [], animations: [] };
163
+ node.fragment = {
164
+ number: fragments.length,
165
+ text: "",
166
+ ns: status.ns,
167
+ events: [],
168
+ animations: []
169
+ };
161
170
  fragments.push(node.fragment);
162
171
  for (let child of node.children) {
163
172
  buildNodeFragmentText(child, status, fragments, node.fragment);
@@ -169,7 +178,13 @@ function buildControlFragmentText(node, status, fragments, currentFragment) {
169
178
  function buildComponentFragmentText(node, status, fragments, currentFragment) {
170
179
  currentFragment.text += ANCHOR_COMMENT;
171
180
  if (node.children.length) {
172
- node.fragment = { number: fragments.length, text: "", events: [], animations: [] };
181
+ node.fragment = {
182
+ number: fragments.length,
183
+ text: "",
184
+ ns: status.ns,
185
+ events: [],
186
+ animations: []
187
+ };
173
188
  fragments.push(node.fragment);
174
189
  for (let child of node.children) {
175
190
  buildNodeFragmentText(child, status, fragments, node.fragment);
@@ -206,7 +221,13 @@ function buildSpecialFragmentText(node, status, fragments, currentFragment) {
206
221
  break;
207
222
  }
208
223
  case ":fill": {
209
- node.fragment = { number: fragments.length, text: "", events: [], animations: [] };
224
+ node.fragment = {
225
+ number: fragments.length,
226
+ text: "",
227
+ ns: status.ns,
228
+ events: [],
229
+ animations: []
230
+ };
210
231
  fragments.push(node.fragment);
211
232
  for (let child of node.children) {
212
233
  buildNodeFragmentText(child, status, fragments, node.fragment);
@@ -363,7 +384,7 @@ function buildFragment(node, status, b, parentName, anchorName) {
363
384
  status.imports.add("t_fragment");
364
385
  const fragmentText = fragment.text.replaceAll("`", "\\`").replaceAll(/\s+/g, " ");
365
386
  b.append(
366
- `const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \`${fragmentText}\`);`
387
+ `const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \`${fragmentText}\`${fragment.ns ? ", true" : ""});`
367
388
  );
368
389
  let fragmentPath = { parent: null, type: "fragment", children: [] };
369
390
  let varPaths = /* @__PURE__ */ new Map();
@@ -1710,12 +1731,7 @@ function buildSlotNode(node, status, b) {
1710
1731
  const slotParentName = node.parentName;
1711
1732
  const slotAnchorName = node.varName;
1712
1733
  b.append(`if ($slots && $slots["${slotName}"]) {`);
1713
- let params = [
1714
- slotParentName,
1715
- slotAnchorName,
1716
- slotHasProps ? propsName : "undefined",
1717
- status.contextProps.length ? "$context" : "undefined"
1718
- ];
1734
+ let params = [slotParentName, slotAnchorName, slotHasProps ? propsName : "undefined", "$context"];
1719
1735
  b.append(`$slots["${slotName}"](${params.join(", ")})`);
1720
1736
  const fill = node.children.find((c) => isSpecialNode(c) && c.tagName === ":fill");
1721
1737
  if (fill && isSpecialNode(fill) && fill.children.length) {
@@ -1971,6 +1987,7 @@ function buildTemplate(template, imports, b) {
1971
1987
  varNames: {},
1972
1988
  fragmentStack: [],
1973
1989
  forVarNames: [],
1990
+ ns: false,
1974
1991
  preserveWhitespace: false
1975
1992
  };
1976
1993
  b.append("");