Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#11536 closed defect (invalid)

dojo.create: the style attribute seems to be ignored by Internet Explorer 7

Reported by: scheid Owned by: anonymous
Priority: high Milestone: tbd
Component: HTML Version: 1.5
Keywords: Cc:
Blocked By: Blocking:

Description

When I use dojo.create and include a style attribute, like this:

div2 = dojo.create("div", {style:"white-space: nowrap;margin-left:12px;font-size:8pt;"}, td);

then all of the style values get ignored in IE 7 (I have not tested other IE versions). The above code works great in Firefox.

I have done a workaround; when I pull out the styles and use dojo.style, like this:

div2 = dojo.create("div", {}, td);
dojo.style(div2, "whiteSpace", "nowrap")
dojo.style(div2, "marginLeft", "12px");
dojo.style(div2, "fontSize", "8pt");

then it renders correctly in IE. I can do the workaround, but this dojo.create issue in IE seems like an bug.

Change History (2)

comment:1 Changed 9 years ago by bill

Component: GeneralHTML
Resolution: invalid
Status: newclosed

You need to pass in a property bag. (The API guide for dojo.create() refers to dojo.attr() which explains this.)

div2 = dojo.create("div", {style: {
     whiteSpace: "nowrap",
     marginLeft: "12px",
     fontSize: "8pt"
 } }, td)

comment:2 Changed 9 years ago by scheid

OK, thanks for the info. I missed that.

Still though, it seems that to be consistent, we should be able to pass in a style string just as we would in an HTML tag. dojo.create handles all other attributes (e.g., id, src, href, etc.) that way, I believe.

Note: See TracTickets for help on using tickets.