Skip to content

Commit 37c19a8

Browse files
authored
Handle empty node list (#241)
Implementation of the fix suggested in issue #230 'Uncaught TypeError: node.getAttribute is not a function when passed an empty node list'
1 parent 3ce10cc commit 37c19a8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/realtime.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export function cancel(node?: HTMLElement): void {
5757
export function render(nodes: HTMLElement | HTMLElement[] | NodeList, locale?: string, opts?: Opts) {
5858
// by .length
5959
// @ts-ignore
60-
const nodeList: HTMLElement[] = nodes.length ? nodes : [nodes];
60+
// supports empty list of nodes
61+
const nodeList: HTMLElement[] = NodeList.prototype.isPrototypeOf(nodes) ? nodes : [nodes];
6162

6263
nodeList.forEach((node: HTMLElement) => {
6364
run(node, getDateAttribute(node), getLocale(locale), opts || {});

0 commit comments

Comments
 (0)