From: SourceForge.net <no...@so...> - 2003-07-18 14:02:54
|
Bugs item #757225, was opened at 2003-06-19 09:33 Message generated for change (Comment added) made by barnabycourt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=757225&group_id=47038 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Barnaby Court (barnabycourt) Assigned to: Nobody/Anonymous (nobody) Summary: Javascript: Support changing the TYPE,ID and NAME attributes Initial Comment: Add support for changing the type of INPUT elments and the ID and NAME of all html elements through javascript. Attached is a test case for the desired functionality. ---------------------------------------------------------------------- >Comment By: Barnaby Court (barnabycourt) Date: 2003-07-18 10:02 Message: Logged In: YES user_id=591975 I have had some degree of success with this but I have found certain cases where use of with (element) {} expression in javascript causes problems. There are 2 problems with it that I have encountered. The first is with the SimpleScriptable.put(...) method. put(...) is being called on the parent scriptable object. I replaced if( htmlElement_ == null ) { super.put(name, start, newValue); return; } with if( htmlElement_ == null ) { super.put(name, start, newValue); if (start != null && start != this) { start.put(name, start, newValue); } return; } and that appeared to fix half the problems. The 2nd is with the SimplScriptable.setName(...) method. The "bound" variable is null and the variable found was incorrect. I am still working on finding a solution for this problem. The test case I used for this is the following: public void testId() throws Exception { final String content = "<html><head><title>foo</title><script>" + "var testElement1 = document.createElement( 'INPUT' );" + "testElement1.id = 'testID1';" + "alert(testElement1.id);" + "var testElement2 = document.createElement( 'INPUT' );" + "with (testElement2) {id = 'testID2';}" + "alert(testElement2.id);" + "</script></head><body>" + "<p>hello world</p>" + "</body></html>"; final List collectedAlerts = new ArrayList(); final HtmlPage page = loadPage(content, collectedAlerts); assertEquals("foo", page.getTitleText()); final List expectedAlerts = Arrays.asList( new String[]{ "testID1","testID2" }); assertEquals( expectedAlerts, collectedAlerts ); } ---------------------------------------------------------------------- Comment By: Mike Bowler (mbowler) Date: 2003-07-18 09:33 Message: Logged In: YES user_id=46756 I seem to recall discussing this one with you via private email but I don't have those emails with me (different machine) and my memory is failing. Can you post a summary of where this bug stands right now? As I recall you were investigating why some elements weren't being initialized correctly. ---------------------------------------------------------------------- Comment By: Barnaby Court (barnabycourt) Date: 2003-06-20 09:21 Message: Logged In: YES user_id=591975 Tha attached patch adds the methods needed to support this functionality. For some reason not all the methods are getting called. Perhaps someone could take a look at the patch and see why. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=757225&group_id=47038 |