Skip to content

Commit

Permalink
Dom: fixed unit converter for decimal values
Browse files Browse the repository at this point in the history
  • Loading branch information
jakearchibald committed Sep 14, 2009
1 parent 69acb71 commit f865550
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/dom/dom.js
Expand Up @@ -636,7 +636,7 @@
}
//this returns cascaded values so needs fixing
r = String(elmCurrentStyle[toStyleProp(prop)]);
if (/^\-?\d+[a-z%]+$/i.test(r) && prop != "font-size") {
if (/^-?[\d\.]+(?!px)[%a-z]+$/i.test(r) && prop != "font-size") {
r = getPixelValue(elm, r, usesYAxis.test(prop)) + "px";
}
}
Expand All @@ -663,8 +663,6 @@
Number
*/
function getPixelValue(element, value, useYAxis) {
if (/\d(px)?$/i.test(value)) { return parseInt(value); }

// Remember the original values
var axisPos = useYAxis ? "top" : "left",
axisPosUpper = useYAxis ? "Top" : "Left",
Expand Down
2 changes: 1 addition & 1 deletion test/glow/dom/dom.js
Expand Up @@ -2026,7 +2026,7 @@ t.test("glow.dom.NodeList.css getting", function() {

//positioning
t.equals(glow.dom.get("#cssTests div.posTest1").css("position"), "absolute", "position");
t.equals(glow.dom.get("#cssTests div.posTest1").css("top"), "60px", "top (em val)");
t.equals(glow.dom.get("#cssTests div.posTest1").css("top"), "66px", "top (em val)");
t.equals(glow.dom.get("#cssTests div.posTest1").css("left"), "30px", "left (px val)");
t.equals(glow.dom.get("#cssTests div.posTest1").css("z-index"), "32", "z-index");
t.equals(glow.dom.get("#cssTests div.posTest2").css("right"), "60px", "right (em val)");
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/screen.css
Expand Up @@ -298,7 +298,7 @@ ul.unitTests span.testStats span {
}
.posTest1 {
position: absolute;
top: 5em;
top: 5.5em;
left: 30px;
z-index: 32;
}
Expand Down

0 comments on commit f865550

Please sign in to comment.