# Feature Request: Async ParseRule.getAttrs()

**URL:** <https://discuss.prosemirror.net/t/feature-request-async-parserule-getattrs/1466>\
**Category:** Uncategorized\
**Created:** [August 15, 2018, 6:25pm UTC](https://discuss.prosemirror.net/t/feature-request-async-parserule-getattrs/1466 "2018-08-15T18:25:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wes-r](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/wes-r/32/77_2.png) [@wes-r](https://discuss.prosemirror.net/u/wes-r)\
**Post date:** [August 15, 2018, 6:25pm UTC](https://discuss.prosemirror.net/t/feature-request-async-parserule-getattrs/1466/1 "2018-08-15T18:25:05Z")

</div>

I’d like to parse `<img/>`'s and grab their original `width` & `height` as I set that as attributes on my image nodes. The best way to do this is by using the `Image.onload()` callback. This means that I’ll have the computed node attributes asynchronously.

Thoughts on how this could be implemented? Is it possible for the calling mechanism of `getAttrs()` to pass a `done` handler? Maybe `getAttrsAsync(done)`?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 16, 2018, 6:01am UTC](https://discuss.prosemirror.net/t/feature-request-async-parserule-getattrs/1466/2 "2018-08-16T06:01:02Z")

</div>

> [@wes-r](#):
>
> Is it possible for the calling mechanism of `getAttrs()` to pass a `done` handler?

Since parsing is synchronous, no, that’s not really something that can be done. If you’re doing the parsing yourself, you can to do something like do a second pass over the parsed document to asynchronously resolve and replace nodes like this. If you want this to happen in paste handlers and such, it’s more complicated (but making paste asynchronous seems like a rather bad idea anyway).

---

<div class="post-metadata">

**Author:** ![wes-r](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/wes-r/32/77_2.png) [@wes-r](https://discuss.prosemirror.net/u/wes-r)\
**Post date:** [August 16, 2018, 6:04pm UTC](https://discuss.prosemirror.net/t/feature-request-async-parserule-getattrs/1466/3 "2018-08-16T18:04:21Z")

</div>

Ah thanks for the response, I figured it was a long shot.
