@ugfoundation/swaralipi-js 0.7.3 → 0.7.4

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.
@@ -540,6 +540,14 @@ var FONT_FACES = Object.entries(NOTATION_FONT_URLS).map(
540
540
  var SWARALIPI_CSS = `
541
541
  ${FONT_FACES}
542
542
 
543
+ /* A custom element is display:inline by default, and Resize Observer
544
+ "Observations do not fire for non-replaced inline Elements" \u2014 they report
545
+ one empty content rect and nothing after
546
+ (https://drafts.csswg.org/resize-observer/). The element's re-fit-on-resize
547
+ is that observer, so without this rule the sheet is fitted once, to whatever
548
+ width it happened to have, and never again. */
549
+ :host { display: block; }
550
+
543
551
  .sw-sheet {
544
552
  font-family: var(--sw-font, 'Noto Sans Bengali', 'Kohinoor Bangla', 'Bangla Sangam MN', 'Nirmala UI', 'Noto Sans Devanagari', sans-serif);
545
553
  font-size: var(--sw-size, 1.125rem);
@@ -1223,11 +1231,16 @@ function createElementClass() {
1223
1231
  });
1224
1232
  this.#resize.observe(this);
1225
1233
  }
1234
+ document.fonts?.addEventListener("loadingdone", this.#onFontsLoaded);
1226
1235
  }
1236
+ #onFontsLoaded = () => {
1237
+ if (this.#doc !== void 0) this.fit();
1238
+ };
1227
1239
  disconnectedCallback() {
1228
1240
  this.#abort?.abort();
1229
1241
  this.#resize?.disconnect();
1230
1242
  this.#resize = void 0;
1243
+ document.fonts?.removeEventListener("loadingdone", this.#onFontsLoaded);
1231
1244
  }
1232
1245
  /** Scale the notation to fit the available width, times the zoom factor. */
1233
1246
  #fit() {
@@ -1326,9 +1339,6 @@ function createElementClass() {
1326
1339
  });
1327
1340
  this.#root.innerHTML = this.#styleFallback() + html;
1328
1341
  this.#fit();
1329
- void document.fonts?.ready.then(() => {
1330
- if (seq === this.#renderSeq) this.fit();
1331
- });
1332
1342
  }
1333
1343
  #renderError(message) {
1334
1344
  const div = document.createElement("div");