Skip to content

Commit 96cc2fb

Browse files
committed
Merge pull request react-bootstrap#438 from aforty/patch-1
Col Push/Pull/Offset value zero support
2 parents 851e4d9 + 3b6ba7a commit 96cc2fb

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

src/Col.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ var Col = React.createClass({
4646

4747
prop = size + 'Offset';
4848
classPart = size + '-offset-';
49-
if (this.props[prop]) {
49+
if (this.props[prop] >= 0) {
5050
classes['col-' + classPart + this.props[prop]] = true;
5151
}
5252

5353
prop = size + 'Push';
5454
classPart = size + '-push-';
55-
if (this.props[prop]) {
55+
if (this.props[prop] >= 0) {
5656
classes['col-' + classPart + this.props[prop]] = true;
5757
}
5858

5959
prop = size + 'Pull';
6060
classPart = size + '-pull-';
61-
if (this.props[prop]) {
61+
if (this.props[prop] >= 0) {
6262
classes['col-' + classPart + this.props[prop]] = true;
6363
}
6464
}, this);
@@ -71,4 +71,4 @@ var Col = React.createClass({
7171
}
7272
});
7373

74-
module.exports = Col;
74+
module.exports = Col;

test/ColSpec.jsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*global describe, it, assert */
2+
3+
var React = require('react');
4+
var ReactTestUtils = require('react/lib/ReactTestUtils');
5+
var Col = require('../lib/Col');
6+
7+
describe('Col', function () {
8+
it('Should set Offset of zero', function () {
9+
var instance = ReactTestUtils.renderIntoDocument(
10+
<Col xsOffset={0} smOffset={0} mdOffset={0} lgOffset={0} />
11+
);
12+
13+
var instanceClassName = instance.getDOMNode().className;
14+
assert.ok(instanceClassName.match(/\bcol-xs-offset-0\b/));
15+
assert.ok(instanceClassName.match(/\bcol-sm-offset-0\b/));
16+
assert.ok(instanceClassName.match(/\bcol-md-offset-0\b/));
17+
assert.ok(instanceClassName.match(/\bcol-lg-offset-0\b/));
18+
});
19+
20+
it('Should set Pull of zero', function () {
21+
var instance = ReactTestUtils.renderIntoDocument(
22+
<Col xsPull={0} smPull={0} mdPull={0} lgPull={0} />
23+
);
24+
25+
var instanceClassName = instance.getDOMNode().className;
26+
assert.ok(instanceClassName.match(/\bcol-xs-pull-0\b/));
27+
assert.ok(instanceClassName.match(/\bcol-sm-pull-0\b/));
28+
assert.ok(instanceClassName.match(/\bcol-md-pull-0\b/));
29+
assert.ok(instanceClassName.match(/\bcol-lg-pull-0\b/));
30+
});
31+
32+
it('Should set Push of zero', function () {
33+
var instance = ReactTestUtils.renderIntoDocument(
34+
<Col xsPush={0} smPush={0} mdPush={0} lgPush={0} />
35+
);
36+
37+
var instanceClassName = instance.getDOMNode().className;
38+
assert.ok(instanceClassName.match(/\bcol-xs-push-0\b/));
39+
assert.ok(instanceClassName.match(/\bcol-sm-push-0\b/));
40+
assert.ok(instanceClassName.match(/\bcol-md-push-0\b/));
41+
assert.ok(instanceClassName.match(/\bcol-lg-push-0\b/));
42+
});
43+
});

0 commit comments

Comments
 (0)