@blueking/bk-weweb 0.0.20 → 0.0.21

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.
@@ -722,6 +722,21 @@ class Style {
722
722
  }
723
723
  else {
724
724
  const cssText = this.resetUrlHost(styleElement.textContent || templateStyle.textContent || '', app.url, this.url);
725
+ // fix https://bugs.chromium.org/p/chromium/issues/detail?id=336876
726
+ if (cssText && app.container instanceof ShadowRoot) {
727
+ let fontContent = '';
728
+ cssText.match(/@font-face\s*\{[^}]+\}/g)?.forEach(fontFace => {
729
+ fontContent += `${fontFace}\n`;
730
+ });
731
+ const rawDocument = app.sandBox?.rawDocument;
732
+ if (rawDocument && fontContent) {
733
+ const fontStyle = rawDocument.createElement('style');
734
+ fontStyle.setAttribute('type', 'text/css');
735
+ fontStyle.setAttribute('powered-by', 'bk-weweb');
736
+ fontStyle.textContent = fontContent;
737
+ rawDocument?.head?.append(fontStyle);
738
+ }
739
+ }
725
740
  styleElement.textContent = cssText;
726
741
  }
727
742
  this.scoped = true;