on master help sign in
Fix the default size of text blocks.
commitd2846a2534ee796b562b5e2234a4fd8c0674dc67 authorevancz <info@elm-lang.org> dateSun 14 Apr 2013, 18:07 (14 years ago) parent1d2b3fc
4 files changed+12−8
libraries/Graphics/Element.elm+1−1 libraries/Native/Graphics/Text.js+2−2 libraries/Native/Utils.js+6−5 libraries/WebSocket.elm+3
libraries/Graphics/Element.elm+1−1
@@ -43,7 +43,7 @@ width : Int -> Element -> Element
4343width nw e = let p = e.props
4444 props = case e.element of
4545 Image _ w h _ -> {p| height <- h/w*nw }
46− RawHtml html -> {p| height <- htmlHeight nw html }
46+ RawHtml html -> {p| height <- let (w,h) = htmlHeight nw html in h}
4747 _ -> p
4848 in { element=e.element, props={props| width <- nw} }
4949
libraries/Native/Graphics/Text.js+2−2
@@ -97,8 +97,8 @@ Elm.Native.Graphics.Text = function(elm) {
9797 _0: '<div style="padding:0;margin:0;text-align:' +
9898 pos + '">' + text + '</div>'
9999 };
100− var w = elm.node.clientWidth;
101− return A3(Element.newElement, w, A2(htmlHeight, w, text), e);
100+ var p = A2(htmlHeight, 0, text);
101+ return A3(Element.newElement, p._0, p._1, e);
102102 }
103103 }
104104
libraries/Native/Utils.js+6−5
@@ -99,15 +99,16 @@ Elm.Native.Utils = function(elm) {
9999 function htmlHeight(width, html) {
100100 var t = document.createElement('div');
101101 t.innerHTML = html;
102− t.style.width = width + "px";
102+ if (width > 0) { t.style.width = width + "px"; }
103103 t.style.visibility = "hidden";
104104 t.style.styleFloat = "left";
105105 t.style.cssFloat = "left";
106106
107− document.body.appendChild(t);
108− var h = t.clientHeight
109− document.body.removeChild(t);
110− return h;
107+ elm.node.appendChild(t);
108+ var w = t.clientWidth;
109+ var h = t.clientHeight;
110+ elm.node.removeChild(t);
111+ return Tuple2(w,h);
111112 }
112113
113114 return elm.Native.Utils = {
libraries/WebSocket.elm+3
@@ -8,3 +8,6 @@ import Native.WebSocket as WS
88-- web-socket server. The input signal holds the outgoing messages,
99-- and the resulting signal contains the incoming ones.
1010open : String -> Signal String -> Signal String
11+
12+-- data Action = Open String | Close String | Send String String
13+-- connections : Signal Action -> Signal String