gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.53k stars 377 forks source link

Cross Compiler Error #1336

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 1327

Found in GWT Release: 1.4RC

Detailed description:  I have a piece of code that creates a span & assigns a style
to it via
the following code, 

   private void setObjectStyle(Element object, String style)
   {
      DOM.setElementAttribute(object, "className", style);
//  DOM.setElementAttribute(object, "className", style+" "+style+"-dynamic");
   }

...

      for(int i=0; i < menuItem.length;i++)
      {
         Element e = DOM.createSpan();
         DOM.setElementProperty(e, "innerText", menuItem[i]);
         setObjectStyle(e, "MenuItem");
         String text = e.toString();
         System.out.println(text);
         menu.addTab(text,true);
      }

the System.out.println(text) produces the following

<span classname="MenuItem">ACTIVITIES</span>

which shows that the expected code was generated, In Firefox the text for menuItem[i]
is not 
rendered, viewing generated source I see

<div class="gwt-TabBarItem" style="white-space: nowrap;">
<span classname="MenuItem"/>
</div>

In Safari 3 (OS X) looking at the Web-Inspector (doesn't support cut & paste) the span
is correctly 
rendered which suggests the problem is related to the Firefox bindings

Workaround if you have one:

Links to the relevant GWT Developer Forum posts:

Reported by Raymond.Sutton on 2007-07-01 18:48:24

dankurka commented 9 years ago
This may not be a GWT bug after all, could be a Firefox bug (not sure) tried  hard coding
the span as follows

      menu.addTab("<span class='TabBarText TabBarText-dynamic'>Activities</span>",true);

which worked as expected, also noticed the Element toString() returned 

<span classname="MenuItem">ACTIVITIES</span>

i.e. it returned classname= not class=, Safari treats these as equivalent firefox dosn't;
tried inserting following 
into the processing loop

      text = text.replace('\"', '\'');
      text = text.replaceAll("classname", "class");

and it worked as expected.

This raises the question "should Element have a toHTML() method"? 

I would see the semantics of such a method to be "return as a String the HTML code
fragment with the same 
semantics as this element"

Reported by Raymond.Sutton on 2007-07-01 19:30:05

dankurka commented 9 years ago

Reported by gwt.team.morrildl on 2007-07-06 15:15:19

dankurka commented 9 years ago

Reported by jgw+personal@google.com on 2008-04-29 14:54:06

dankurka commented 9 years ago

Reported by sumitchandel+legacy@google.com on 2008-05-02 16:54:04

dankurka commented 9 years ago

Reported by bruce+personal@google.com on 2008-10-21 21:58:15

dankurka commented 9 years ago
If you are still experiencing this issue with the latest version of GWT, can you 
update the issue tracker?

Reported by amandapsurya on 2008-12-05 21:44:08

dankurka commented 9 years ago

Reported by acc%google.com@gtempaccount.com on 2008-12-12 01:00:43

dankurka commented 9 years ago

Reported by kurka.daniel on 2012-12-16 13:22:17