title: NS_ERROR_UNEXPECTED error in Firefox using Dojo
body: <p>I'm having a strange issue that's being thrown in Firefox when using my Dojo (v.1.10.0) application.</p>
  
  <p>Here is the following error that I'm seeing in Firefox:</p>
  
  <pre><code>Exception 
      { message: "",
        result: 2147549183, 
        name: "NS_ERROR_UNEXPECTED", 
        filename: "http://localhost:8888/dojo/on.js", 
        lineNumber: 354, 
        columnNumber: 0, 
        inner: null, 
        data: null 
      } 
    ""
  </code></pre>
  
  <p>Unfortunately, I'm not sure where to go with this in my application. Can anyone point me in the right direction?</p>
  
  <p>On line 354 of dojo/on, this is happening:</p>
  
  <pre><code> if(has("dom-addeventlistener")){
      // emitter that works with native event handling
      on.emit = function(target, type, event){
          if(target.dispatchEvent &amp;&amp; document.createEvent){
              // use the native event emitting mechanism if it is available on the target object
              // create a generic event               
              // we could create branch into the different types of event constructors, but 
              // that would be a lot of extra code, with little benefit that I can see, seems 
              // best to use the generic constructor and copy properties over, making it 
              // easy to have events look like the ones created with specific initializers
              var ownerDocument = target.ownerDocument || document;
              var nativeEvent = ownerDocument.createEvent("HTMLEvents");
              nativeEvent.initEvent(type, !!event.bubbles, !!event.cancelable);
              // and copy all our properties over
              for(var i in event){
                  if(!(i in nativeEvent)){
                      nativeEvent[i] = event[i];
                  }
              }
              return target.dispatchEvent(nativeEvent) &amp;&amp; nativeEvent; // Line 354
          }
          return syntheticDispatch.apply(on, arguments); // emit for a non-node
      };
  }
  </code></pre>