0

com.google.gwt.user.client.Element removes quotes in attributes when Application works on IE. I have element with <div id="mytestid"> </div>. I want to remove this id and set a new one, but when app runs on IE (I use IE9) I can not change the id properly because it puts single or double quotes around my id.

For example:

      Element el = elem;
      el.removeAttribute("id");
      String id = "\"mynewid"\";  //I tried all possible combinations foe escaping  
      el.setAttribute("id", id);  

But Element id is id='"mynewid"' - it puts single quotes around double quotes.

Thank you in advance!

Braj
  • 46,415
  • 5
  • 60
  • 76
user2739823
  • 397
  • 1
  • 7
  • 24
  • 2
    I don't understand, you have quotes in your value, and you complain that IE is using them as-is? (the single quotes are so that your double quotes are not interpreted as quotes around the value, but part of the value; IE could have serialized it as `id=""mynewid""` too) – Thomas Broyer Mar 21 '14 at 16:46
  • The problem is that if I set id to element on internet explorer this id of element is not in quotes THanks – user2739823 Mar 21 '14 at 16:57
  • Single and double quotes are allowed for attributes: http://stackoverflow.com/questions/2373074/single-vs-double-quotes-vs If you set the Attribues value to "value" the Browser needs to either escape the quotes &quot; or escape with the other attribute "terminator" – Christian Kuetbach Mar 21 '14 at 17:05
  • single quotes and double quotes are used interchangeably in JavaScript. – Braj Mar 21 '14 at 17:06

1 Answers1

2

What is wrong with this?

Its working as expected. You have set it "mynewid" by using id = "\"mynewid\"".

Try this one if you don't want double quotes around new id.

  Element el = elem;
  el.removeAttribute("id");
  String id = "mynewid";  
  el.setAttribute("id", id);  

Screenshot - Firefox 26.0

enter image description here

Screenshot - IE9

enter image description here

Braj
  • 46,415
  • 5
  • 60
  • 76