@edoxen/browser 0.1.3 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edoxen/browser",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Astro-based browser for edoxen YAML data — drop in your data and ship a resolutions archive site.",
5
5
  "type": "module",
6
6
  "license": "BSD-2-Clause",
@@ -15,7 +15,7 @@ interface FetchResponse {
15
15
  facetYears?: number[]
16
16
  }
17
17
 
18
- function appendListItem(list: ParentNode, item: SearchableItem, basePath: string): void {
18
+ function buildListItem(item: SearchableItem, basePath: string): HTMLLIElement {
19
19
  const li = document.createElement('li')
20
20
  li.className = 'edoxen-search-filter__result'
21
21
  const link = document.createElement('a')
@@ -28,7 +28,7 @@ function appendListItem(list: ParentNode, item: SearchableItem, basePath: string
28
28
  badge.textContent = item.bodyType
29
29
  li.appendChild(badge)
30
30
  }
31
- list.appendChild(li)
31
+ return li
32
32
  }
33
33
 
34
34
  function makeFacetChip(label: string, count: number, active: boolean, onToggle: () => void): HTMLElement {
@@ -73,7 +73,6 @@ class SearchFilter extends HTMLElement {
73
73
  }
74
74
 
75
75
  private renderShell(): void {
76
- this.innerHTML = ''
77
76
  const form = document.createElement('form')
78
77
  form.className = 'edoxen-search-filter__form'
79
78
  form.setAttribute('role', 'search')
@@ -100,7 +99,7 @@ class SearchFilter extends HTMLElement {
100
99
  results.setAttribute('data-role', 'results')
101
100
  form.appendChild(results)
102
101
 
103
- this.appendChild(form)
102
+ this.replaceChildren(form)
104
103
  }
105
104
 
106
105
  private render(): void {
@@ -108,7 +107,7 @@ class SearchFilter extends HTMLElement {
108
107
  const resultsEl = this.querySelector('[data-role="results"]')
109
108
  if (!facetsEl || !resultsEl) return
110
109
 
111
- facetsEl.innerHTML = ''
110
+ facetsEl.replaceChildren()
112
111
  const bodies = new Set<string>()
113
112
  const kinds = new Set<string>()
114
113
  const years = new Set<number>()
@@ -135,16 +134,16 @@ class SearchFilter extends HTMLElement {
135
134
  facetsEl.appendChild(chip)
136
135
  }
137
136
 
138
- resultsEl.innerHTML = ''
137
+ resultsEl.replaceChildren()
139
138
  const matches = filterItems(this.items, this.state)
140
139
  if (matches.length === 0) {
141
140
  const empty = document.createElement('li')
142
141
  empty.className = 'edoxen-empty'
143
142
  empty.textContent = 'No matches.'
144
- resultsEl.appendChild(empty)
143
+ resultsEl.replaceChildren(empty)
145
144
  return
146
145
  }
147
- for (const item of matches) appendListItem(resultsEl, item, this.basePath)
146
+ resultsEl.replaceChildren(...matches.map((item) => buildListItem(item, this.basePath)))
148
147
  }
149
148
 
150
149
  private syncHash(): void {
@@ -155,11 +154,10 @@ class SearchFilter extends HTMLElement {
155
154
  }
156
155
 
157
156
  private renderError(message: string): void {
158
- this.innerHTML = ''
159
157
  const p = document.createElement('p')
160
158
  p.className = 'edoxen-search-filter__error'
161
159
  p.textContent = message
162
- this.appendChild(p)
160
+ this.replaceChildren(p)
163
161
  }
164
162
  }
165
163
 
@@ -21,8 +21,7 @@ class UrnCopy extends HTMLElement {
21
21
  }, 1500)
22
22
  }
23
23
  })
24
- this.innerHTML = ''
25
- this.appendChild(btn)
24
+ this.replaceChildren(btn)
26
25
  }
27
26
  }
28
27