Comparing version 4.3.0 to 4.4.0
{ | ||
"name": "rquery", | ||
"main": "rquery.js", | ||
"version": "4.3.0", | ||
"version": "4.4.0", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Andrew Hanna <percyhanna@gmail.com>" |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "4.3.0", | ||
"version": "4.4.0", | ||
"repository": { | ||
@@ -16,0 +16,0 @@ "type": "git", |
@@ -89,6 +89,9 @@ (function (rquery) { | ||
if (TestUtils.isDOMComponent(component)) { | ||
if (prop === 'className') { | ||
return component.className; | ||
} else { | ||
return component.getAttribute(prop); | ||
switch (prop) { | ||
case 'checked': | ||
case 'className': | ||
return component[prop]; | ||
default: | ||
return component.getAttribute(prop); | ||
} | ||
@@ -102,3 +105,10 @@ } else { | ||
if (TestUtils.isDOMComponent(component)) { | ||
return component.hasAttribute(prop); | ||
switch (prop) { | ||
case 'checked': | ||
case 'className': | ||
return prop in component; | ||
default: | ||
return component.hasAttribute(prop); | ||
} | ||
} else { | ||
@@ -273,6 +283,6 @@ return component.props && prop in component.props; | ||
context.filterScope(function (component) { | ||
// if the component is composite, then look at its DOM node to match | ||
// this allows the composite component to be kept in the context | ||
// composite components must be found by their displayName, not its | ||
// root DOM node, | ||
if (TestUtils.isCompositeComponent(component)) { | ||
component = rquery_getDOMNode(component); | ||
return false; | ||
} | ||
@@ -296,3 +306,9 @@ | ||
matchClass: function (className, match) { | ||
var classes = className.split(' '); | ||
var classes; | ||
if (window.SVGAnimatedString && className instanceof SVGAnimatedString) { | ||
className = className.animVal; | ||
} | ||
classes = className.split(' '); | ||
return classes.indexOf(match[1]) !== -1; | ||
@@ -692,2 +708,10 @@ }, | ||
rquery.prototype.disabled = function (name) { | ||
if (this.length < 1) { | ||
throw new Error('$R#disabled requires at least one component. No components in current scope.'); | ||
} | ||
return rquery_getDOMNode(this[0]).disabled; | ||
}; | ||
rquery.prototype.checked = function (value) { | ||
@@ -708,5 +732,7 @@ this._notAllowedInShallowMode('checked'); | ||
} else { | ||
if (this.components[0]) { | ||
return rquery_getDOMNode(this.components[0]).checked; | ||
if (this.length < 1) { | ||
throw new Error('$R#checked requires at least one component. No components in current scope.'); | ||
} | ||
return rquery_getDOMNode(this[0]).checked; | ||
} | ||
@@ -713,0 +739,0 @@ }; |
@@ -300,2 +300,37 @@ var TestUtils = React.addons.TestUtils; | ||
describe('#disabled', function () { | ||
describe('when called on a disabled input', function () { | ||
before(function () { | ||
this.component = TestUtils.renderIntoDocument(React.createElement('input', { disabled: true })); | ||
this.$r = $R(this.component); | ||
}); | ||
it('returns true', function () { | ||
expect(this.$r.disabled()).to.equal(true); | ||
}); | ||
}); | ||
describe('when called on an enabled input', function () { | ||
before(function () { | ||
this.component = TestUtils.renderIntoDocument(React.createElement('input', { disabled: false })); | ||
this.$r = $R(this.component); | ||
}); | ||
it('returns false', function () { | ||
expect(this.$r.disabled()).to.equal(false); | ||
}); | ||
}); | ||
describe('when called on a non-input', function () { | ||
before(function () { | ||
this.component = TestUtils.renderIntoDocument(React.createElement('div')); | ||
this.$r = $R(this.component); | ||
}); | ||
it('returns undefined', function () { | ||
expect(this.$r.disabled()).to.be.undefined; | ||
}); | ||
}); | ||
}); | ||
describe('#checked', function () { | ||
@@ -302,0 +337,0 @@ before(function () { |
@@ -241,3 +241,3 @@ function runSelectors (shallow) { | ||
if (!shallow) { | ||
describe('internal composite DOM components', function () { | ||
describe('DOM components that are children of DOM components', function () { | ||
before(function () { | ||
@@ -248,11 +248,25 @@ this.$r = run('div > button'); | ||
it('finds the button components', function () { | ||
expect(this.$r).to.have.length(3); | ||
expect(this.$r).to.have.length(2); | ||
}); | ||
it('only matches DOM components', function () { | ||
expect(this.$r.components.map(tagName)).to.be.eql(['BUTTON', 'BUTTON']); | ||
}); | ||
}); | ||
describe('composite components that are children of DOM components', function () { | ||
before(function () { | ||
this.$r = run('div > ChildComponent'); | ||
}); | ||
it('finds one component', function () { | ||
expect(this.$r).to.have.length(1); | ||
}); | ||
it('finds the composite component', function () { | ||
expect(TestUtils.isCompositeComponentWithType(this.$r[1], ChildComponent)).to.be.true; | ||
expect(TestUtils.isCompositeComponentWithType(this.$r[0], ChildComponent)).to.be.true; | ||
}); | ||
}); | ||
it('finds composite components that are children of composite components', function () { | ||
it('composite components that are children of composite components', function () { | ||
this.$r = run('MyComponent > ChildComponent'); | ||
@@ -695,3 +709,3 @@ expect(this.$r).to.have.length(1); | ||
it('finds all the descendants that do not match any of the union expressions', function () { | ||
expect(this.$r).to.have.length(shallow ? 4 : 2); | ||
expect(this.$r).to.have.length(shallow ? 4 : 3); | ||
}); | ||
@@ -712,2 +726,3 @@ | ||
'A', | ||
undefined, | ||
'DIV' | ||
@@ -733,2 +748,3 @@ ]; | ||
'button', | ||
undefined, | ||
undefined | ||
@@ -735,0 +751,0 @@ ]; |
73034
12
1804