stx-router 0.2.332 → 0.2.333

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.
Files changed (2) hide show
  1. package/dist/client.js +11 -0
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -1010,6 +1010,16 @@ else {
1010
1010
  }
1011
1011
  return '';
1012
1012
  });
1013
+ // A <style> inside a script is a string the script owns \u2014 a web
1014
+ // component's shadow-DOM CSS, typically \u2014 not a page style. Lifted into
1015
+ // <head> it restyles the whole document (its bare button rule shrank
1016
+ // every button on the page) and the component loses it. Hold scripts
1017
+ // aside while the fragment's own styles are collected.
1018
+ var heldScripts=[];
1019
+ cleanFrag=cleanFrag.replace(new RegExp('<scr'+'ipt\\\\b[^>]*>[\\\\s\\\\S]*?<\\\\/scr'+'ipt>','gi'),function(m){
1020
+ heldScripts.push(m);
1021
+ return '<!--stx-held-script-'+(heldScripts.length-1)+'-->';
1022
+ });
1013
1023
  cleanFrag=cleanFrag.replace(new RegExp('<sty'+'le\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/sty'+'le>','gi'),function(m,attrs,css){
1014
1024
  if(attrs.indexOf('data-css')!==-1){
1015
1025
  fragCss=css;
@@ -1024,6 +1034,7 @@ else {
1024
1034
  if(hrefMatch&&hrefMatch[2])fragCssHrefs.push(hrefMatch[2]);
1025
1035
  return '';
1026
1036
  });
1037
+ cleanFrag=cleanFrag.replace(new RegExp('<!--stx-held-script-(\\\\d+)-->','g'),function(m,i){return heldScripts[Number(i)]});
1027
1038
  // Remove old page styles (not css \u2014 that gets merged)
1028
1039
  document.querySelectorAll('style[data-stx-page]').forEach(function(s){s.remove()});
1029
1040
  // Merge css CSS from fragment into existing css style
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stx-router",
3
3
  "type": "module",
4
- "version": "0.2.332",
4
+ "version": "0.2.333",
5
5
  "description": "File-based router for STX — .stx template discovery, nested layouts, typed route params, middleware, and client-side SPA navigation.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",