on master help sign in
cosmetic: better spacing and naming in setProps
7a98a2fEvan Czaplicki
runtime/Render/Element.js+21−11
@@ -7,20 +7,27 @@ var newElement = Utils.newElement, colorToCss = Utils.colorToCss,
7 addTransform = Utils.addTransform, removeTransform = Utils.removeTransform,
7 addTransform = Utils.addTransform, removeTransform = Utils.removeTransform,
8 fromList = Utils.fromList, eq = Utils.eq;
8 fromList = Utils.fromList, eq = Utils.eq;
9
9
10−function setProps(elem, e) {
10+function setProps(elem, node) {
11 var props = elem.props;
11 var props = elem.props;
12+
12 var element = elem.element;
13 var element = elem.element;
13 var width = props.width - (element.adjustWidth || 0);
14 var width = props.width - (element.adjustWidth || 0);
14 var height = props.height - (element.adjustHeight || 0);
15 var height = props.height - (element.adjustHeight || 0);
15− e.style.width = (width |0) + 'px';
16+ node.style.width = (width |0) + 'px';
16− e.style.height = (height|0) + 'px';
17+ node.style.height = (height|0) + 'px';
18+
17 if (props.opacity !== 1) {
19 if (props.opacity !== 1) {
18− e.style.opacity = props.opacity;
20+ node.style.opacity = props.opacity;
19 }
21 }
22+
20 if (props.color.ctor === 'Just') {
23 if (props.color.ctor === 'Just') {
21− e.style.backgroundColor = colorToCss(props.color._0);
24+ node.style.backgroundColor = colorToCss(props.color._0);
25+ }
26+
27+ if (props.tag !== '') {
28+ node.id = props.tag;
22 }
29 }
23− if (props.tag !== '') { e.id = props.tag; }
30+
24 if (props.href !== '') {
31 if (props.href !== '') {
25 var a = newElement('a');
32 var a = newElement('a');
26 a.href = props.href;
33 a.href = props.href;
@@ -30,17 +37,20 @@ function setProps(elem, e) {
30 a.style.left = 0;
37 a.style.left = 0;
31 a.style.display = 'block';
38 a.style.display = 'block';
32 a.style.position = 'absolute';
39 a.style.position = 'absolute';
33− e.style.position = 'relative';
40+ node.style.position = 'relative';
34 a.style.pointerEvents = 'auto';
41 a.style.pointerEvents = 'auto';
35− e.appendChild(a);
42+ node.appendChild(a);
36 }
43 }
44+
37 if (props.hover.ctor !== '_Tuple0') {
45 if (props.hover.ctor !== '_Tuple0') {
38− addHover(e, props.hover);
46+ addHover(node, props.hover);
39 }
47 }
48+
40 if (props.click.ctor !== '_Tuple0') {
49 if (props.click.ctor !== '_Tuple0') {
41− addClick(e, props.click);
50+ addClick(node, props.click);
42 }
51 }
52+
43− return e;
53+ return node;
44}
54}
45
55
46function addClick(e, handler) {
56function addClick(e, handler) {