@smilodon/core 1.1.0 → 1.1.2

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/dist/index.js CHANGED
@@ -2572,10 +2572,15 @@ class AngularEnhancedSelect extends HTMLElement {
2572
2572
  }
2573
2573
  }
2574
2574
  _initializeStyles() {
2575
- // Create scoped styles for this component instance
2575
+ // Check if styles already exist for this component type
2576
+ const existingStyle = document.head.querySelector('style[data-component="angular-enhanced-select-shared"]');
2577
+ if (existingStyle) {
2578
+ // Styles already injected, skip
2579
+ return;
2580
+ }
2581
+ // Create scoped styles for this component type (shared across all instances)
2576
2582
  this._styleElement = document.createElement('style');
2577
- this._styleElement.setAttribute('data-component', 'angular-enhanced-select');
2578
- this._styleElement.setAttribute('data-id', this._uniqueId);
2583
+ this._styleElement.setAttribute('data-component', 'angular-enhanced-select-shared');
2579
2584
  const p = this.PREFIX; // shorthand
2580
2585
  this._styleElement.textContent = `
2581
2586
  /* Host styles - applied to <angular-enhanced-select> */
@@ -2891,8 +2896,26 @@ class AngularEnhancedSelect extends HTMLElement {
2891
2896
  min-height: 44px;
2892
2897
  }
2893
2898
  `;
2894
- // Append to document head
2895
- document.head.appendChild(this._styleElement);
2899
+ // Safely append to document head (check if document is ready)
2900
+ if (document.head) {
2901
+ try {
2902
+ document.head.appendChild(this._styleElement);
2903
+ }
2904
+ catch (e) {
2905
+ console.warn('[AngularEnhancedSelect] Could not inject styles:', e);
2906
+ // Fallback: inject after a delay
2907
+ setTimeout(() => {
2908
+ try {
2909
+ if (this._styleElement && !this._styleElement.parentNode) {
2910
+ document.head.appendChild(this._styleElement);
2911
+ }
2912
+ }
2913
+ catch (err) {
2914
+ console.error('[AngularEnhancedSelect] Style injection failed:', err);
2915
+ }
2916
+ }, 0);
2917
+ }
2918
+ }
2896
2919
  }
2897
2920
  _createContainer() {
2898
2921
  const container = document.createElement('div');