Skip to content

Instantly share code, notes, and snippets.

@boucher
Created March 11, 2010 21:54
Show Gist options
  • Select an option

  • Save boucher/329712 to your computer and use it in GitHub Desktop.

Select an option

Save boucher/329712 to your computer and use it in GitHub Desktop.
diff --git a/AppKit/Platform/DOM/CPPlatformString.j b/AppKit/Platform/DOM/CPPlatformString.j
index 7b82f44..96c1dcc 100644
--- a/AppKit/Platform/DOM/CPPlatformString.j
+++ b/AppKit/Platform/DOM/CPPlatformString.j
@@ -67,11 +67,15 @@ var DOMSpanElement = nil,
DOMSpanElement = DOMIFrameDocument.createElement("span");
DOMSpanElement.style.position = "absolute";
- DOMSpanElement.style.whiteSpace = "pre";
DOMSpanElement.style.visibility = "visible";
DOMSpanElement.style.padding = "0px";
DOMSpanElement.style.margin = "0px";
+ try {
+ DOMSpanElement.style.whiteSpace = "pre";
+ }
+ catch (e) {}
+
DOMDivElement.appendChild(DOMSpanElement);
}
@@ -93,16 +97,29 @@ var DOMSpanElement = nil,
if (!aWidth)
{
style.width = "";
- style.whiteSpace = "pre";
+
+ try {
+ style.whiteSpace = "pre";
+ }
+ catch (e) {}
+
+ style.wordWrap = "normal";
}
else
{
style.width = ROUND(aWidth) + "px";
+ try
+ {
+ style.whiteSpace = "-o-pre-wrap";
+ style.whiteSpace = "-pre-wrap";
+ style.whiteSpace = "-moz-pre-wrap";
+ style.whiteSpace = "pre-wrap";
+ } catch(e)
+ {
+ //some versions of IE throw exceptions for unsupported properties.
+ }
+
style.wordWrap = "break-word";
- style.whiteSpace = "-o-pre-wrap";
- style.whiteSpace = "-pre-wrap";
- style.whiteSpace = "-moz-pre-wrap";
- style.whiteSpace = "pre-wrap";
}
style.font = [aFont cssString];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment