From: SourceForge.net <no...@so...> - 2005-02-28 17:30:55
|
Bugs item #757225, was opened at 2003-06-19 15:33 Message generated for change (Comment added) made by mguillem You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=757225&group_id=47038 Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Barnaby Court (barnabycourt) >Assigned to: Marc Guillemot (mguillem) 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: Marc Guillemot (mguillem) Date: 2005-02-28 18:30 Message: Logged In: YES user_id=402164 the type of inputs can now be changed too. Please open an other issue if you still have problems with the "with" keyword. ---------------------------------------------------------------------- Comment By: Marc Guillemot (mguillem) Date: 2005-01-18 15:34 Message: Logged In: YES user_id=402164 Just a comment to "the type of an input cannot be changed from javascript": this can't be done currently, but should be allowed as it is fully legal and works with IE and Moz. ---------------------------------------------------------------------- Comment By: Brad Clarke (yourgod) Date: 2005-01-18 00:10 Message: Logged In: YES user_id=257129 there seem to be three bugs showing up in the test case: document.createElement('input') fails all by itself - issue #1002140 no properties are writeable on form controls inside a with() block (seems to try and write to the window object instead) the type of an input cannot be changed from javascript ---------------------------------------------------------------------- Comment By: Barnaby Court (barnabycourt) Date: 2003-10-02 22:57 Message: Logged In: YES user_id=591975 With help from the rhino development team I have found a solution for the issue. It requires SimpleScriptable to override the has(String, Scriptable) method. This is so that has returns true for all the predefined html attribues. One possible implementation of this is public boolean has(String name, Scriptable start) { boolean parentValue = super.has(name, start); if (parentValue == true) { return parentValue; } else { if (name == null ) { return false; } Map propertyMap = getPropertyMap(); if (propertyMap != null && propertyMap.containsKey (name)) { return true; } else { return false; } } } This is causing a failure in HtmlPageTest.testOnLoadHandler_ScriptName(...) and WindowTest.testSetLocation(...). I will continue to look into why this is causing problems for those 2 tests. If anyone has any ideas I would welcome any suggetions. ---------------------------------------------------------------------- Comment By: Barnaby Court (barnabycourt) Date: 2003-10-02 22:36 Message: Logged In: YES user_id=591975 With help from the rhino development team I have found a solution for the issue. It requires SimpleScriptable to override the has(String, Scriptable) method. This is so that has returns true for all the predefined html attribues. One possible implementation of this is public boolean has(String name, Scriptable start) { boolean parentValue = super.has(name, start); if (parentValue == true) { return parentValue; } else { if (name == null ) { return false; } Map propertyMap = getPropertyMap(); if (propertyMap != null && propertyMap.containsKey (name)) { return true; } else { return false; } } } This is causing a failure in HtmlPageTest.testOnLoadHandler_ScriptName(...) and WindowTest.testSetLocation(...). I will continue to look into why this is causing problems for those 2 tests. If anyone has any ideas I would welcome any suggetions. ---------------------------------------------------------------------- Comment By: Barnaby Court (barnabycourt) Date: 2003-10-02 18:40 Message: Logged In: YES user_id=591975 I have a patch that addresses the type and name attributes. For some reason I am still having a problem getting the id attribute to work using the "with (element) {...}" javascript call. The reason it isn't working as that the put method is not being called on SimpleScriptable. I have opened a defect (#221025) for this in the Rhino Bugzilla database. There may be something in the configuration I am missing but I can set the id using "element.id = 'foo';" and it works fine so I am assuming this is a Rhino issue. I will continue to track the issue with the Rhino development folks and report back here once the issue has been addressed there. ---------------------------------------------------------------------- Comment By: Barnaby Court (barnabycourt) Date: 2003-07-18 16: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 15: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 15: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 |