Make sure named item cache is always valid HTMLCollection::updateIdNameCache()

Make sure named item cache is always valid HTMLCollection::updateIdNameCache().
The method was previously creating and setting the cache map first and then
traverse the DOM tree to populate it. However, finding matches in the DOM tree
can cause HTMLCollection::invalidateCache() to be called under certain
circumstances. Therefore, this patch updates updateIdNameCache() so that the
cache map is set *after* traversing the DOM tree.

BUG=360474
R=jochen@chromium.org, eseidel@chromium.org
TEST=fast/dom/htmlcollection-selectedOptions-namedItem-crash.html

Review URL: https://codereview.chromium.org/225023034

git-svn-id: svn://svn.chromium.org/blink/trunk@171062 bbb929c8-8fbe-4397-9dbb-9b2b20218538