[WF2] HTMLFormElement.accept vs. function accept(){}

HTML4 has a <form accept> attribute but DOM2 HTML doesn't have a  
corresponding HTMLFormElement.accept attribute. WF2 fixes this bug and  
includes HTMLFormElement.accept. However, this has caused problems for us  
since some sites depend on it not being supported by having a function  
called accept() and call that in event handler attributes on the form,  
like so:

    <script> function accept() { ... } </script>
    <form onsubmit="accept()"> ...

In Opera, accept refers to the DOM attribute instead of the function,  
resulting in a TypeError exception. This is because DOM attributes take  
predecense over functions -- compare with e.g. "method" in other browsers:

    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%3Cscript%3E%20function%20method()%20{%20alert(1)%20}%20%3C%2Fscript%3E%3Cform%20onsubmit%3D%27try%20{%20method()%3B%20}%20catch(e)%20{%20w(e)%20}%20return%20false%27%3E%3Cinput%20type%3Dsubmit%3E%3Cscript%3E%20document.forms[0].firstChild.click()%20%3C%2Fscript%3E

There are some ways to fix this problem.

   1) Make the .accept DOM attribute not override functions in scope.
   2) Remove support for .accept DOM attribute but keep the content  
attribute.
   3) Remove support for both .accept and <form accept>.

(1) is hairy. (2) is in line with HTML4/DOM2 HTML, but is inconsistent. I  
don't see any problems with (3). <form accept> is only "fallback" for  
<input type=file accept> anyway, so, not very useful, and besides it's not  
really used in the wild.

So I'd suggest that the <form accept> attribute be removed from WF2.

-- 
Simon Pieters
Opera Software

Received on Wednesday, 20 February 2008 17:07:34 UTC