HTML Standard Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/1998

File a bug

SVNBugCommentTime (UTC)
1998define what happens when you set onclick='' on a document outside a Window2008-08-05 07:51
Index: source
===================================================================
--- source	(revision 1997)
+++ source	(revision 1998)
@@ -29708,8 +29708,11 @@
   <code>script</code> element section, which says scripts don't run
   when the document isn't active.</p>
 
+
   <h5 id="event-handler-attributes">Event handler attributes</h5>
 
+  <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cscript%3E%0Aw(a%3Ddocument.implementation.createDocument(null%2C%20null%2C%20null))%3B%0Aw(a.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'html')))%3B%0Aw(b%3Da.firstChild.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'body')))%3B%0Aw(b.test%20%3D%20w)%3B%0Aw(b.setAttribute('onclick'%2C%20'test(%22fire%3A%20%22%20%2B%20event)'))%3B%0Aw(b.onclick)%3B%0Aw(e%3Da.createEvent('Event'))%3B%0Aw(e.initEvent('click'%2C%20false%2C%20false))%3B%0Aw(b.dispatchEvent(e))%3B%0A%3C%2Fscript%3E -->
+
   <p><span>HTML elements</span> can have <dfn>event handler
   attributes</dfn> specified. These act as bubbling event listeners
   for the element on which they are specified.</p>
@@ -29734,21 +29737,23 @@
   href="#refsECMA262">[ECMA262]</a></p>
 
   <!-- SCRIPT EXEC -->
-  <p>When an event handler content attribute is set, its new value
-  must be interpreted as the body of an anonymous function with a
-  single argument called <code>event</code>, with the new function's
-  scope chain being linked from the activation object of the handler,
-  to the element, to the element's <code>form</code> element if it is
-  a form control, to the <code>Document</code> object, to the
-  <code>Window</code> object of the <span>browsing context</span> of
-  that <code>Document</code>. The function's <code>this</code>
-  parameter must be the <code>Element</code> object representing the
-  element. The resulting function must then be set as the value of the
-  corresponding event handler attribute, and the new value must be set
-  as the value of the content attribute. If the given function body
-  fails to compile, then the corresponding event handler attribute
-  must be set to null instead (the content attribute must still be
-  updated to the new value, though).</p>
+  <p>When an event handler content attribute is set, if the element is
+  owned by a <code>Document</code> that is in a <span>browsing
+  context</span>, its new value must be interpreted as the body of an
+  anonymous function with a single argument called <code>event</code>,
+  with the new function's scope chain being linked from the activation
+  object of the handler, to the element, to the element's
+  <code>form</code> element if it is a form control, to the
+  <code>Document</code> object, to the <code>Window</code> object of
+  the <span>browsing context</span> of that <code>Document</code>. The
+  function's <code>this</code> parameter must be the
+  <code>Element</code> object representing the element. The resulting
+  function must then be set as the value of the corresponding event
+  handler attribute, and the new value must be set as the value of the
+  content attribute. If the given function body fails to compile, then
+  the corresponding event handler attribute must be set to null
+  instead (the content attribute must still be updated to the new
+  value, though).</p>
 
   <p class="note">See ECMA262 Edition 3, sections 10.1.6 and 10.2.3,
   for more details on activation objects. <a
@@ -29760,6 +29765,11 @@
   must be the <code>Document</code> object that owns the event handler
   content attribute that was set.</p>
 
+  <p>When an event handler content attribute is set on an element
+  owned by a <code>Document</code> that is not in a <span>browsing
+  context</span>, the corresponding event handler attribute is not
+  changed.</>
+
   <p class="big-issue">How do we allow non-JS event handlers?</p>
 
   <p><dfn>Event handler DOM attributes</dfn>, on setting, must set the

|