Skip to content

Commit

Permalink
FLUID-4685: Fixed the issue that 1em is always applied to body elemen…
Browse files Browse the repository at this point in the history
…t at page load regardless its original font size.
  • Loading branch information
cindyli committed Apr 3, 2012
1 parent b049653 commit 775c800
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/webapp/components/uiOptions/js/UIEnhancer.js
Expand Up @@ -352,8 +352,9 @@ var fluid_1_5 = fluid_1_5 || {};
};

fluid.uiEnhancer.getPx2EmFactor = function (container, fontSizeMap) {
// The base font size is the computed font size of the container's parent element unless the container itself has been a "body" tag
if (container.get(0).tagName !== "BODY") {
// The base font size is the computed font size of the container's parent element unless the container itself
// has been the DOM root element "HTML" which is NOT detectable with this algorithm
if (container.get(0).tagName !== "HTML") {
container = container.parent();
}
return fluid.uiEnhancer.getTextSizeInPx(container, fontSizeMap);
Expand Down
Expand Up @@ -59,12 +59,19 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.assertEquals("Things are still styled with 'last-class' ", 2, $(".last-class").length);
});

tests.test("getPx2EmFactor", function () {
tests.test("getPx2EmFactor & getTextSizeInEm", function () {
expect(2);

var container = $(".flt-baseFontSize-child");
var uiEnhancer = fluid.uiEnhancer(container, uiEnhancerOptions);
var px2emFactor = fluid.uiEnhancer.getPx2EmFactor(container, uiEnhancer.options.fontSizeMap);

jqUnit.assertEquals("Check that the factor is pulled from the container correctly", 8, px2emFactor);

var container = $("html");
var fontSizeInEm = fluid.uiEnhancer.getTextSizeInEm(container, uiEnhancer.options.fontSizeMap);

jqUnit.assertEquals("Unable to detect the text size in em for the DOM root element <html>. Always return 1em.", 1, fontSizeInEm);
});

tests.test("TextSizer", function () {
Expand Down

0 comments on commit 775c800

Please sign in to comment.