Support toDomElements returning an empty array

Change-Id: I7c526a206a5166b601c1e9dff679a195a0029e6a
Merge "Support toDomElements returning an empty array"