HTMLElement.style.setAttribute throw style.setAttribute is not a function
See original GitHub issueGWT version : 2.8.2 elemental2 version : 1.0.0-RC1
using the setAttribute
from elemental2 CSSStyleDeclaration
gives is not a function
, while using setProperty
works.
to repeat the case add the following code snippet
HTMLElement element= (HTMLElement) DomGlobal.document.createElement("div");
element.style.setProperty("padding-left","10px");//works
element.style.setAttribute("padding-right","10px");//fail
DomGlobal.document.body.appendChild(element);
the exception
App.java:13 Uncaught TypeError: element_0_g$.style.setAttribute is not a function
at wzd_g$.xzd_g$ [as onModuleLoad_0_g$] (App.java:13)
at Array.crb_g$ (org_00046sample_0004…MethodHolder.java:3)
at initializeModules_0_g$ (ModuleUtils.java:44)
at Dp_g$ (Impl.java:309)
at Gp_g$ (Impl.java:368)
at Impl.java:78
at wqb_g$ (ModuleUtils.java:55)
at App.java:9
i noticed that in the MDN documentation there is no setAttribute
method
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration
if it is something need to be fixed and i can make a PR for, i will gladly do. Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
TypeError: setAttribute is not a function in JavaScript
To solve the "setAttribute is not a function" error, make sure to only call the setAttribute method on valid DOM elements and place...
Read more >element.setAttribute is not a function - Stack Overflow
In that case, the element doesn't exist yet in the document. You need to run the code after the element is created, say...
Read more >Uncaught TypeError on setting attribute in JavaScript
In this approach, you may get an Uncaught TypeError saying “elem.setAttribute is not a function”. This happens because you are trying to call ......
Read more >HTML DOM Element setAttribute() Method - W3Schools
Definition and Usage. The setAttribute() method sets a new value to an attribute. If the attribute does not exist, it is created first....
Read more >Use of SetAttribute() in JavaScript with Examples - eduCBA
In the function, we are getting the item using 'document.getElementById(“button”)'; Then we are adding to attribute value style and background color as yellow ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This will be much easier to notice by elemental2 users if https://github.com/google/jsinterop-generator/pull/6 is accepted, so that the
@Deprecated
is on the java types as well.Ok that’s actually what they did so I think we can close this.