@tsrx/core 0.1.29 → 0.1.30

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
@@ -3,7 +3,7 @@
3
3
  "description": "Core compiler infrastructure for TSRX syntax",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.1.29",
6
+ "version": "0.1.30",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
@@ -779,19 +779,25 @@ function apply_css_definition_metadata(
779
779
  }
780
780
 
781
781
  /**
782
+ * Pruning runs from the fragment visitor, before the walker has descended into
783
+ * the subtree and stamped walker paths, so each collected element gets its
784
+ * ancestor chain (`metadata.path`) here — descendant/sibling selector matching
785
+ * in `prune_css` reads it.
786
+ *
782
787
  * @param {any} value
783
788
  * @param {any[]} [elements]
784
789
  * @param {TransformContext | null} [transform_context]
790
+ * @param {any[]} [path]
785
791
  * @returns {any[]}
786
792
  */
787
- function collect_css_prunable_elements(value, elements = [], transform_context = null) {
793
+ function collect_css_prunable_elements(value, elements = [], transform_context = null, path = []) {
788
794
  if (!value || typeof value !== 'object') {
789
795
  return elements;
790
796
  }
791
797
 
792
798
  if (Array.isArray(value)) {
793
799
  for (const child of value) {
794
- collect_css_prunable_elements(child, elements, transform_context);
800
+ collect_css_prunable_elements(child, elements, transform_context, path);
795
801
  }
796
802
  return elements;
797
803
  }
@@ -810,15 +816,18 @@ function collect_css_prunable_elements(value, elements = [], transform_context =
810
816
 
811
817
  if (value.type === 'JSXElement' && value.metadata?.native_tsrx) {
812
818
  if (!is_style_element(value)) {
819
+ set_node_path_metadata(value, path);
813
820
  elements.push(value);
814
821
  }
815
822
  }
816
823
 
824
+ const child_path = value.type ? [...path, value] : path;
825
+
817
826
  for (const key of Object.keys(value)) {
818
827
  if (key === 'loc' || key === 'start' || key === 'end' || key === 'metadata' || key === 'css') {
819
828
  continue;
820
829
  }
821
- collect_css_prunable_elements(value[key], elements, transform_context);
830
+ collect_css_prunable_elements(value[key], elements, transform_context, child_path);
822
831
  }
823
832
 
824
833
  return elements;