title: Why does this Prototype Code in Magento crash?
body: <p>For the last hour and a half I've trace Javascript calls in a Magento shop I'm building, because I have the strange effect that, when checking out, I can not leave page 2  (shipping address) of the onepage checkout, unless I switch from "send to this address" to "send to another address". </p>
  
  <p>I've traced it down to this piece of javascript code in form.js, residing in Regionupdater.setMarkDisplay (line 254 ff.)</p>
  
  <p>Since I'm a jquery man myself I'm not really in the loop with prototype functionality but I'm assuming .up and .down are practically what jquery does with .parent(s) and .children()?!</p>
  
  <pre><code>elem = $(elem);
  var labelElement = elem.up(0).down('label &gt; span.required') ||
                     elem.up(1).down('label &gt; span.required') ||
                     elem.up(0).down('label.required &gt; em') ||
                     elem.up(1).down('label.required &gt; em'); 
  </code></pre>
  
  <p>elem is the region select field in the form.
  I'm assuming it's trying to find the label for this field (which exists). But both the "elem.up(0)" fragments apparently throw an </p>
  
  <pre><code>[Exception... "An invalid or illegal string was specified" code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)"]
  </code></pre>
  
  <p>I've no idea what triggers this.</p>