Comparing version 0.0.3 to 0.0.5
{ | ||
"name": "rquery", | ||
"main": "rquery.js", | ||
"version": "0.0.3", | ||
"version": "0.0.5", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Andrew Hanna <percyhanna@gmail.com>" |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.0.3", | ||
"version": "0.0.5", | ||
"repository": { | ||
@@ -13,0 +13,0 @@ "type": "git", |
@@ -1,2 +0,16 @@ | ||
(function (global) { | ||
(function (rquery) { | ||
// Module systems magic dance. | ||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { | ||
// NodeJS | ||
module.exports = rquery; | ||
} else if (typeof define === "function" && define.amd) { | ||
// AMD | ||
define(['react'], function (React) { | ||
return rquery(React); | ||
}); | ||
} else { | ||
// Other environment (usually <script> tag): assume React is already loaded. | ||
window.$R = rquery(React); | ||
} | ||
}(function (React) { | ||
'use strict'; | ||
@@ -85,5 +99,9 @@ | ||
function rQuery (components) { | ||
function rquery (components) { | ||
if (!isArray(components)) { | ||
components = [components]; | ||
if (components) { | ||
components = [components]; | ||
} else { | ||
components = []; | ||
} | ||
} | ||
@@ -99,3 +117,3 @@ | ||
rQuery.prototype.find = function (selector) { | ||
rquery.prototype.find = function (selector) { | ||
var predicate = parseSelector(selector); | ||
@@ -105,3 +123,17 @@ return this._generate(predicate); | ||
rQuery.prototype._generate = function (predicate) { | ||
rquery.prototype.findComponent = function (type) { | ||
return this._generate(function (component) { | ||
return TestUtils.isCompositeComponentWithType(component, type); | ||
}); | ||
}; | ||
rquery.prototype.get = function (index) { | ||
if (this.components[index]) { | ||
return new rquery(this.components[index]); | ||
} else { | ||
return new rquery(); | ||
} | ||
}; | ||
rquery.prototype._generate = function (predicate) { | ||
var matches = [].concat.apply([], this.components.map(function (component) { | ||
@@ -111,6 +143,6 @@ return TestUtils.findAllInRenderedTree(component, predicate); | ||
return new rQuery(matches); | ||
return new rquery(matches); | ||
}; | ||
rQuery.prototype.simulateEvent = function (eventName, eventData) { | ||
rquery.prototype.simulateEvent = function (eventName, eventData) { | ||
for (var i = 0; i < this.components.length; i++) { | ||
@@ -142,3 +174,3 @@ TestUtils.Simulate[eventName](this.components[i].getDOMNode(), eventData); | ||
EVENT_NAMES.forEach(function (eventName) { | ||
rQuery.prototype[eventName] = function (eventData) { | ||
rquery.prototype[eventName] = function (eventData) { | ||
this.simulateEvent(eventName, eventData); | ||
@@ -148,4 +180,4 @@ }; | ||
var $R = global.$R = function (components, selector) { | ||
var $r = new rQuery(components); | ||
var $R = function (components, selector) { | ||
var $r = new rquery(components); | ||
@@ -158,2 +190,4 @@ if (selector) { | ||
}; | ||
}(this)); | ||
return $R; | ||
})); |
Sorry, the diff of this file is not supported yet
19108
392