Opened 11 years ago

Closed 11 years ago

#5372 closed enhancement (fixed)

[patch][cla]Difficult to set float with dojo.style

Reported by: guest Owned by: sjmiles
Priority: high Milestone: 1.1
Component: HTML Version: 1.0
Keywords: Cc: mmantel2@…
Blocked By: Blocking:

Description

To set a node's float, you have to do something like:

dojo.style(node, dojo.isIE ? "styleFloat" : "cssFloat", "right");

It would be nice if you could simply do:

dojo.style(node, "float", "right");

and have Dojo take care of the browser check.

"styleFloat" works in IE and Opera, "cssFloat" works in Mozilla, Safari, and Opera.

Attachments (2)

float.patch (875 bytes) - added by dante 11 years ago.
proposed fix. tested manually in FF2 + IE7
sjm_float.patch (855 bytes) - added by sjmiles 11 years ago.
Possible alternate patch, see comment.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 11 years ago by dylan

Milestone: 1.2

comment:2 Changed 11 years ago by dante

first line of dojo.style function:

style = (style == "float" ? (dojo.isIE ? "styleFloat" : "cssFloat") : style);

seems like a fix.

Changed 11 years ago by dante

Attachment: float.patch added

proposed fix. tested manually in FF2 + IE7

comment:3 Changed 11 years ago by Adam Peller

Summary: Difficult to set float with dojo.style[patch][cla]Difficult to set float with dojo.style

comment:4 Changed 11 years ago by alex

wait, I though we'd merged this? It really isn't landing for 1.1?

comment:5 Changed 11 years ago by Adam Peller

Milestone: 1.21.1

should we use "cssFloat" instead of "float", if that's what most browsers do?

comment:6 Changed 11 years ago by sjmiles

Here is my proposed fix. I didn't commit it because I have not had time to write a unit test. If any of you guys want to commit this, or dante's version, it's ok with me.

above dojo.style:

	var _floatStyle = dojo.isIE ? "styleFloat" : "cssFloat";
	var _floatAliases = { "cssFloat": _floatStyle, "styleFloat": _floatStyle, "float": _floatStyle };

inside dojo.style:

	style = _floatAliases[style] || style;

Attached.

Changed 11 years ago by sjmiles

Attachment: sjm_float.patch added

Possible alternate patch, see comment.

comment:7 Changed 11 years ago by dante

+1 from me. that means "float":"left", "cssFloat":"left" and styleFloat:"left" all will work. and compresses slightly better. go sjmiles.

comment:8 Changed 11 years ago by sjmiles

Resolution: fixed
Status: newclosed

(In [12934]) Fixes #5372. !strict

Note: See TracTickets for help on using tickets.