> summary
goog.style.preWrap(element) does not support FireFox 3.5 (GECKO 1.9.1+). The
function sets the white-space css style to the vendor specific style
'-moz-pre-wrap', which is deprecated and no longer supported in FireFox 3.5.
The CSS3 style "pre-wrap" is supported for 3.5+ (actually it should work in 3.0
as wells).
Mozilla documentation: https://developer.mozilla.org/en/CSS/white-space
> What steps will reproduce the problem?
1. Using FireFox 3.5+, set text content of an element to something which
includes line breaks / white space formatting / etc
2. call goog.style.preWrap(ele) and pass in the element
3. using firebug/etc, you can now see that the element rejects the white-space
style of "-moz-pre-wrap" style in 3.5+
4. manually set the style to 'pre-wrap' and verify that the text is rendered
with proper formatting
> What is the expected output? What do you see instead?
expected: honoring of white space formatting when rendering, according to the
pre-wrap style
> What version of the product are you using? On what operating system?
OS X, FireFox 3.5+. However, this should be the same across all os's according
to https://developer.mozilla.org/en/CSS/white-space
> Please provide any additional information below.
Modifying the function to verify the userAgent version, and that it is greater
than 1.9.1 (FF 3.5) before using '-moz-pre-wrap' fixes this issue. The same
sort of solution is also applied for Opera as opera 8+ supports the css3
'per-wrap' style and no longer needs the vendor specific one.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
diff of the change:
diff current_src patched_src
7,8c7,8
< * Mozilla: white-space: -moz-pre-wrap;
< * Opera: white-space: -o-pre-wrap;
---
> * Mozilla 1.0/1.9: white-space: -moz-pre-wrap;
> * Opera 4.0: white-space: -o-pre-wrap;
18c18
< } else if (goog.userAgent.GECKO) {
---
> } else if (goog.userAgent.GECKO && !goog.userAgent.isVersion('1.9.1')) {
20c20
< } else if (goog.userAgent.OPERA) {
---
> } else if (goog.userAgent.OPERA && !goog.userAgent.isVersion('8.0')) {
26d25
<
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
entire function, w/ changes:
/**
* Sets 'white-space: pre-wrap' for a node (x-browser).
*
* There are as many ways of specifying pre-wrap as there are browsers.
*
* CSS3/IE8: white-space: pre-wrap;
* Mozilla 1.0/1.9: white-space: -moz-pre-wrap;
* Opera 4.0: white-space: -o-pre-wrap;
* IE6/7: white-space: pre; word-wrap: break-word;
*
* @param {Element} el Element to enable pre-wrap for.
*/
goog.style.setPreWrap = function(el) {
var style = el.style;
if (goog.userAgent.IE && !goog.userAgent.isVersion('8')) {
style.whiteSpace = 'pre';
style.wordWrap = 'break-word';
} else if (goog.userAgent.GECKO && !goog.userAgent.isVersion('1.9.1')) {
style.whiteSpace = '-moz-pre-wrap';
} else if (goog.userAgent.OPERA && !goog.userAgent.isVersion('8.0')) {
style.whiteSpace = '-o-pre-wrap';
} else {
style.whiteSpace = 'pre-wrap';
}
};
thanks,
mikie
@mrexroad
Original issue reported on code.google.com by mike.rexroad on 21 Jul 2010 at 11:16
Original issue reported on code.google.com by
mike.rexroad
on 21 Jul 2010 at 11:16