assign-gingerly 0.0.57 → 0.0.58

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.
@@ -73,7 +73,7 @@ export class LazyLoadHandler {
73
73
  }
74
74
  else {
75
75
  if (transitional) {
76
- ensureHideStyle(lhsTarget.getRootNode());
76
+ ensureHideStyle(lhsTarget.getRootNode(), hideClass, hideCss);
77
77
  withTransition(startMarker, 'show', true, () => {
78
78
  this.cloneAndInsertSync(instantiate, startMarker, endMarker, lhsTarget, resolvedParams);
79
79
  });
@@ -89,7 +89,7 @@ export class LazyLoadHandler {
89
89
  [startMarker, endMarker] = createMarkers(lhsTarget, name, method);
90
90
  }
91
91
  if (transitional) {
92
- ensureHideStyle(lhsTarget.getRootNode());
92
+ ensureHideStyle(lhsTarget.getRootNode(), hideClass, hideCss);
93
93
  withTransition(startMarker, 'show', true, () => {
94
94
  this.cloneAndInsertSync(instantiate, startMarker, endMarker, lhsTarget, resolvedParams);
95
95
  });
@@ -102,7 +102,7 @@ export class LazyLoadHandler implements AssignFromHandler {
102
102
  } else {
103
103
  // Content was removed (forget mode) — re-clone
104
104
  if (transitional) {
105
- ensureHideStyle(lhsTarget.getRootNode());
105
+ ensureHideStyle(lhsTarget.getRootNode(), hideClass, hideCss);
106
106
  withTransition(startMarker, 'show', true, () => {
107
107
  this.cloneAndInsertSync(instantiate, startMarker!, endMarker!, lhsTarget, resolvedParams);
108
108
  });
@@ -118,7 +118,7 @@ export class LazyLoadHandler implements AssignFromHandler {
118
118
  [startMarker, endMarker] = createMarkers(lhsTarget, name, method);
119
119
  }
120
120
  if (transitional) {
121
- ensureHideStyle(lhsTarget.getRootNode());
121
+ ensureHideStyle(lhsTarget.getRootNode(), hideClass, hideCss);
122
122
  withTransition(startMarker, 'show', true, () => {
123
123
  this.cloneAndInsertSync(instantiate, startMarker!, endMarker!, lhsTarget, resolvedParams);
124
124
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assign-gingerly",
3
- "version": "0.0.57",
3
+ "version": "0.0.58",
4
4
  "description": "This package provides a utility function for carefully merging one object into another.",
5
5
  "homepage": "https://github.com/bahrus/assign-gingerly#readme",
6
6
  "bugs": {
@@ -77,9 +77,9 @@ export function withTransition(markerNode, direction, transitional, domMutation)
77
77
  }
78
78
 
79
79
  /**
80
- * Track which rootNodes already have the hide style injected.
80
+ * Track which (rootNode, className) combos already have styles injected.
81
81
  */
82
- const styleInjected = new WeakSet();
82
+ const styleInjected = new WeakMap();
83
83
 
84
84
  /**
85
85
  * Default CSS class name for hidden elements during transitions.
@@ -87,7 +87,7 @@ const styleInjected = new WeakSet();
87
87
  export const DEFAULT_HIDE_CLASS = 'ag-hide';
88
88
 
89
89
  /**
90
- * Ensure the hide class style is injected into the rootNode (once per rootNode).
90
+ * Ensure the hide class style is injected into the rootNode (once per rootNode + className combo).
91
91
  *
92
92
  * @param {any} rootNode - The Document, ShadowRoot, or element root to inject into
93
93
  * @param {string} [hideClass='ag-hide'] - CSS class name
@@ -100,8 +100,14 @@ export function ensureHideStyle(rootNode, hideClass = DEFAULT_HIDE_CLASS, hideCs
100
100
  target = document.head;
101
101
  }
102
102
 
103
- if (styleInjected.has(target)) return;
104
- styleInjected.add(target);
103
+ let injectedClasses = styleInjected.get(target);
104
+ if (!injectedClasses) {
105
+ injectedClasses = new Set();
106
+ styleInjected.set(target, injectedClasses);
107
+ }
108
+
109
+ if (injectedClasses.has(hideClass)) return;
110
+ injectedClasses.add(hideClass);
105
111
 
106
112
  const style = document.createElement('style');
107
113
  style.textContent = `.${hideClass} { ${hideCss} }`;
@@ -91,9 +91,9 @@ export function withTransition(
91
91
  }
92
92
 
93
93
  /**
94
- * Track which rootNodes already have the hide style injected.
94
+ * Track which (rootNode, className) combos already have styles injected.
95
95
  */
96
- const styleInjected = new WeakSet<object>();
96
+ const styleInjected = new WeakMap<object, Set<string>>();
97
97
 
98
98
  /**
99
99
  * Default CSS class name for hidden elements during transitions.
@@ -106,7 +106,7 @@ export const DEFAULT_HIDE_CLASS = 'ag-hide';
106
106
  const DEFAULT_HIDE_CSS = `display: none`;
107
107
 
108
108
  /**
109
- * Ensure the hide class style is injected into the rootNode (once per rootNode).
109
+ * Ensure the hide class style is injected into the rootNode (once per rootNode + className combo).
110
110
  *
111
111
  * @param rootNode - The Document, ShadowRoot, or element root to inject into
112
112
  * @param hideClass - CSS class name (default: 'ag-hide')
@@ -123,8 +123,14 @@ export function ensureHideStyle(
123
123
  target = document.head;
124
124
  }
125
125
 
126
- if (styleInjected.has(target)) return;
127
- styleInjected.add(target);
126
+ let injectedClasses = styleInjected.get(target);
127
+ if (!injectedClasses) {
128
+ injectedClasses = new Set();
129
+ styleInjected.set(target, injectedClasses);
130
+ }
131
+
132
+ if (injectedClasses.has(hideClass)) return;
133
+ injectedClasses.add(hideClass);
128
134
 
129
135
  const style = document.createElement('style');
130
136
  style.textContent = `.${hideClass} { ${hideCss} }`;