-
Notifications
You must be signed in to change notification settings - Fork 1
/
react-coffeescript-glue.js
70 lines (62 loc) · 1.89 KB
/
react-coffeescript-glue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(function (root, factory) {
if (typeof exports === 'object') {
module.exports = factory(require('react'));
}
else if (typeof define === 'function' && define.amd) {
define(['react'], factory);
}
else {
var globalAlias = 'ReactGlue';
var namespace = globalAlias.split('.');
var parent = root;
for ( var i = 0; i < namespace.length-1; i++ ) {
if ( parent[namespace[i]] === undefined ) parent[namespace[i]] = {};
parent = parent[namespace[i]];
}
parent[namespace[namespace.length-1]] = factory(root['React']);
}
}(this, function(React) {
function _requireDep(name) {
return {'react': React}[name];
}
var _bundleExports = (function() {
var ReactGlue, define_tag, method, tag, _ref,
__slice = [].slice;
ReactGlue = {};
define_tag = function(tag) {
if (!({}.hasOwnProperty.call(React.DOM, tag) && tag !== 'injection')) {
return;
}
return ReactGlue[tag] = function() {
var attr, attrs, children, key, options, value, _i, _len, _ref, _ref1;
attrs = arguments[0], children = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (Array.isArray(attrs)) {
options = {
className: ''
};
for (_i = 0, _len = attrs.length; _i < _len; _i++) {
attr = attrs[_i];
if (typeof attr === 'string') {
options.className += ' ' + attr;
} else {
for (key in attr) {
value = attr[key];
options[key] = value;
}
}
}
return (_ref = React.DOM)[tag].apply(_ref, [options].concat(__slice.call(children)));
} else {
return (_ref1 = React.DOM)[tag].apply(_ref1, [attrs].concat(__slice.call(children)));
}
};
};
_ref = React.DOM;
for (tag in _ref) {
method = _ref[tag];
define_tag(tag);
}
return ReactGlue;
}).call(this);
return _bundleExports;
}));