Skip to content

Commit 134ea88

Browse files
committed
Update README.
1 parent 7b5bf12 commit 134ea88

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ Returns an anchor element containing a button that when clicked will download a
5959
DOM.download(await new Promise(resolve => canvas.toBlob(resolve)))
6060
```
6161

62+
The *object* may also be specified as a function, in which case the function is called when the download button is clicked. For example:
63+
64+
```js
65+
DOM.download(() => new Promise(resolve => canvas.toBlob(resolve)))
66+
```
67+
68+
If the *object* is a promise, or if it is a function that returns a promise, the promise will be awaited before downloading. If necessary, an additional click may be required to download the asynchronous value.
69+
6270
<a href="#DOM_element" name="DOM_element">#</a> DOM.<b>element</b>(<i>name</i>[, <i>attributes</i>]) [<>](https://github.com/observablehq/stdlib/blob/master/src/dom/element.js "Source")
6371

6472
Returns a new element with the specified *name*. For example, to create an empty H1 element:

0 commit comments

Comments
 (0)