JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://fb.me/react-with-addons-0.8.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
<div id='content' foo='alice' bar='has' bav='a cat' />
<!-- have foo, bar & bav available as props in <Swoosh />? -->
JavaScript 1.7
/** @jsx React.DOM */
var InheritsDomAttributes = {
componentDidMount: function(rootNode) {
var hasNextProps = false;
var nextProps = {};
var parentNode = rootNode.parentNode;
Object.keys(parentNode.attributes).forEach(function(key) {˜n
var namedNode;
// NamedNodeMaps have an attribute named "length" that
// should not be considered a set attribute.
if (key !== "length") {
hasNextProps = true;
namedNode = parentNode.attributes[key];
nextProps[namedNode.name] = namedNode.value;
}
});
if (hasNextProps) this.setProps(nextProps);
}
};
var Swoosh = React.createClass({
mixins: [InheritsDomAttributes],
render: function() {
return (
<div className="swoosh">
Boom.
</div>
);
}
});
React.renderComponent(
<Swoosh />,
document.getElementById('content')
);