on master help sign in
cosmetic: better spacing and naming in setProps
commit7a98a2f0a4463e8c5738642c79aa6c9e0af64c40 authorEvan Czaplicki <info@elm-lang.org> dateThu 24 Jul 2014, 22:23 (12 years ago) parent62d3a02
1 file changed+21−11
runtime/Render/Element.js+21−11
runtime/Render/Element.js+21−11
@@ -7,20 +7,27 @@ var newElement = Utils.newElement, colorToCss = Utils.colorToCss,
77 addTransform = Utils.addTransform, removeTransform = Utils.removeTransform,
88 fromList = Utils.fromList, eq = Utils.eq;
99
10−function setProps(elem, e) {
10+function setProps(elem, node) {
1111 var props = elem.props;
12+
1213 var element = elem.element;
1314 var width = props.width - (element.adjustWidth || 0);
1415 var height = props.height - (element.adjustHeight || 0);
15− e.style.width = (width |0) + 'px';
16− e.style.height = (height|0) + 'px';
16+ node.style.width = (width |0) + 'px';
17+ node.style.height = (height|0) + 'px';
18+
1719 if (props.opacity !== 1) {
18− e.style.opacity = props.opacity;
20+ node.style.opacity = props.opacity;
1921 }
22+
2023 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;
2229 }
23− if (props.tag !== '') { e.id = props.tag; }
30+
2431 if (props.href !== '') {
2532 var a = newElement('a');
2633 a.href = props.href;
@@ -30,17 +37,20 @@ function setProps(elem, e) {
3037 a.style.left = 0;
3138 a.style.display = 'block';
3239 a.style.position = 'absolute';
33− e.style.position = 'relative';
40+ node.style.position = 'relative';
3441 a.style.pointerEvents = 'auto';
35− e.appendChild(a);
42+ node.appendChild(a);
3643 }
44+
3745 if (props.hover.ctor !== '_Tuple0') {
38− addHover(e, props.hover);
46+ addHover(node, props.hover);
3947 }
48+
4049 if (props.click.ctor !== '_Tuple0') {
41− addClick(e, props.click);
50+ addClick(node, props.click);
4251 }
43− return e;
52+
53+ return node;
4454}
4555
4656function addClick(e, handler) {