Permalink
Browse files

Make `Element.Layout` properly interpret computed non-integer pixel v…

…alues. (e.g., Firefox can report "12.5px" as a computed style value.) (henrymazza)
  • Loading branch information...
1 parent c9a9d1c commit 91e5582652e428364a24df8c90c9d1db3ae22703 @savetheclocktower savetheclocktower committed Mar 19, 2010
Showing with 6 additions and 2 deletions.
  1. +2 −0 CHANGELOG
  2. +4 −2 src/dom/layout.js
View
@@ -1,3 +1,5 @@
+* Make `Element.Layout` properly interpret computed non-integer pixel values. (e.g., Firefox can report "12.5px" as a computed style value.) (henrymazza)
+
* Fix deprecated Selector.matchElements. (Tobie Langel)
* Make Object.keys ES5 compliant. (Tobie Langel)
View
@@ -23,8 +23,10 @@
}
// Non-IE browsers will always return pixels if possible.
- if ((/^\d+(px)?$/i).test(value)) {
- return window.parseInt(value, 10);
+ // (We use parseFloat instead of parseInt because Firefox can return
+ // non-integer pixel values.)
+ if ((/^\d+(\.\d+)?(px)?$/i).test(value)) {
+ return window.parseFloat(value);
}
// When IE gives us something other than a pixel value, this technique

0 comments on commit 91e5582

Please sign in to comment.