pretty-toc 1.1.5 → 1.1.6

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/index.mjs +12 -7
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -247,7 +247,6 @@ function prettyToc(option) {
247
247
  <html>
248
248
  <head><meta charset="utf-8"></head>
249
249
  <body>
250
- <strong>Hello from iframe!</strong>
251
250
  <script is:inline data-astro-rerun>
252
251
  const currentLocale = window.parent.location.pathname.split('/')[1] || '${opt.locale || "en-US"}';
253
252
  const languageMap = ${JSON.stringify(opt.languageMap).replaceAll("\"", "'")} || ${JSON.stringify(DEFAULT_LANGUAGE_MAP).replaceAll("\"", "'")};
@@ -275,12 +274,18 @@ function prettyToc(option) {
275
274
  }
276
275
  }
277
276
 
278
- syncTocTitle(currentLocale, languageMap);
279
- toggleToc();
280
-
281
- window.parent.addEventListener('load', function() {
282
- syncTocTitle(currentLocale, languageMap);
283
- toggleToc();
277
+ window.addEventListener('load', function() {
278
+ if (window.parent.document.readyState === 'complete') {
279
+ syncTocTitle(currentLocale, languageMap);
280
+ toggleToc();
281
+ } else {
282
+ window.parent.document.addEventListener('readystatechange', event => {
283
+ if (event.target.readyState === 'complete') {
284
+ syncTocTitle(currentLocale, languageMap);
285
+ toggleToc();
286
+ }
287
+ });
288
+ }
284
289
  });
285
290
  <\/script>
286
291
  &lt;/body&gt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pretty-toc",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "type": "module",
5
5
  "description": "A Table of Contents generation plugin for the Satteri markdown parser library.",
6
6
  "keywords": [