Bugzilla – Bug 812
javascript return statement in event handlers not accepted
Last modified: 2011-01-20 10:44:12 CET
The validator does not accept the javascript return statement in event handlers. For example the input: <!DOCTYPE html><html><head><title></title></head><body onload="return"><p></p></body></html> returns the error "invalid return". This is caused by the org.whattf.datatype.FunctionBody checkValid function that calls a non-function-body javascript-parser. Simplistic hack to work around this problem is to change in syntax/relaxng/datatype/java/classes/org/whattf/datatype/FunctionBody.java line 48: Reader reader = new BufferedReader((new StringReader( literal.toString()))); to: Reader reader = new BufferedReader((new StringReader( "function(event){" + literal.toString() + "}")));
Thanks very much. Reading through the Rhino API docs, I couldn't find any canonical way it provides for doing this, but your proposed change seems to be a reasonable way, so I went ahead and made the change as you proposed. https://bitbucket.org/validator/syntax/changeset/dc4d70a03fab I have it deployed for testing at http://www.w3.org/html/check If you give it a try their and notice any problems, feel free to reopen this bug or of course to raise others if they're not related to this on.