xtk domutils: use Object.keys and ensure that value is defined

(integrated from master branch change 4ec3d07 by Todd Whiteman <toddw@activestate.com>)