@internetarchive/bookreader 5.0.0-107 → 5.0.0-108

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-107",
3
+ "version": "5.0.0-108",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "type": "module",
6
6
  "files": [
@@ -10,8 +10,8 @@ import { sharedStyles } from '../../css/sharedStyles.js';
10
10
  import { svgToDataUrl } from '../../util/lit.js';
11
11
  /** @typedef {import('@/src/plugins/search/plugin.search.js').SearchInsideMatch} SearchInsideMatch */
12
12
 
13
- const checkmarkIconData = svgToDataUrl(checkmarkIconTemplate.strings[0]);
14
- const closeIconData = svgToDataUrl(closeIconTemplate.strings[0]);
13
+ const checkmarkIconData = svgToDataUrl(checkmarkIconTemplate);
14
+ const closeIconData = svgToDataUrl(closeIconTemplate);
15
15
 
16
16
  export class IABookSearchResults extends LitElement {
17
17
  static get properties() {
package/src/util/lit.js CHANGED
@@ -2,9 +2,16 @@ import { css } from 'lit';
2
2
 
3
3
  /**
4
4
  * Convert an SVG string to a data URL usable in CSS
5
- * @param {string} svgString
5
+ * @param {import('lit').TemplateResult} svgTemplate - The SVG template to convert
6
6
  * @returns {import('lit').CSSResult}
7
7
  */
8
- export function svgToDataUrl(svgString) {
8
+ export function svgToDataUrl(svgTemplate) {
9
+ const svgString = (
10
+ // No clue why, on prod the template from the close icon comes in as a class instead of a TemplateResult.
11
+ // Might be a discrepancy with lit versions.
12
+ svgTemplate.prototype?.render() ||
13
+ // Otherwise it's a normal TemplateResult.
14
+ svgTemplate.strings[0]
15
+ );
9
16
  return css([`data:image/svg+xml;base64,${btoa(svgString.replace(/\n/g, ' '))}`]);
10
17
  }