Skip to content

Commit 2d37e6c

Browse files
committed
Break up DOM module, simplify the props API.
1 parent d601548 commit 2d37e6c

File tree

8 files changed

+1107
-450
lines changed

8 files changed

+1107
-450
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
purescript-react
22
================
33

4-
[![Maintainer: paf31](https://img.shields.io/badge/maintainer-paf31-lightgrey.svg)](http://github.com/paf31)
4+
[![Maintainer: paf31](https://img.shields.io/badge/maintainer-paf31-lightgrey.svg)](http://github.com/paf31) ![React: 0.12.2](https://img.shields.io/badge/react-0.12.2-lightgrey.svg)
55

66
Low-level React Bindings for PureScript.
77

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"devDependencies": {
1919
"purescript-console": "^0.1.0",
2020
"purescript-dom": "^0.1.1",
21-
"react": "~0.10.0"
21+
"react": "~0.12.2"
2222
}
2323
}

src/React/DOM.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,24 @@
55

66
function mkProps(props) {
77
var result = {};
8+
89
for (var i = 0, len = props.length; i < len; i++) {
910
var prop = props[i];
10-
var name = prop.constructor.name;
11-
name = name[0].toLowerCase() + name.substring(1);
12-
var val = prop.value0;
13-
/* Until React.js handles data and aria like style*/
14-
/* we have to unload the properties.*/
15-
if (name === 'data' || name === 'aria') {
16-
for (var subprop in val) {
17-
if (val.hasOwnProperty(subprop)) {
18-
result[name + '-' + subprop] = val[subprop];
19-
}
11+
12+
for (var key in prop) {
13+
if (prop.hasOwnProperty(key)) {
14+
result[key] = prop[key];
2015
}
21-
} else {
22-
result[name] = val;
2316
}
2417
}
18+
2519
return result;
2620
};
2721

2822
exports.mkDOM = function(tagName) {
29-
var ctor = window.React.DOM[tagName];
3023
return function(props) {
3124
return function(children) {
32-
var p = props.length > 0 ? mkProps(props) : null;
33-
return ctor.apply(ctor, [p].concat(children));
25+
return React.createElement(tagName, props.length > 0 ? mkProps(props) : null, children);
3426
}
3527
}
3628
};

0 commit comments

Comments
 (0)