Skip to content
This repository has been archived by the owner on Sep 20, 2018. It is now read-only.

Commit

Permalink
[changed] Integrate bill@2.0.0; stabilize and consolidate APIs across…
Browse files Browse the repository at this point in the history
… collection

types; tests.
  • Loading branch information
jquense committed Dec 26, 2015
1 parent 869a0d2 commit 9b40e02
Show file tree
Hide file tree
Showing 14 changed files with 1,381 additions and 561 deletions.
655 changes: 483 additions & 172 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ _extends(eQuery.fn, {

if (instance === null) instance = _reactDom2['default'].render(utils.wrapStateless(element), mount);

return _instance2['default'](instance, utils.getInternalInstance(instance), mount);
return _instance2['default'](instance, utils.(instance), mount);
},

shallowRender: function shallowRender(props) {
Expand Down
2 changes: 1 addition & 1 deletion lib/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var $ = _QueryCollection2['default'](utils.match, _bill2['default'], function in

mount = mount || context && context._mountPoint || utils.getMountPoint(first);

this.context = context && context.context || context || utils.getInternalInstance(utils.getRootInstance(mount));
this.context = context && context.context || context || utils.(utils.getRootInstance(mount));

this._mountPoint = mount;
this._privateInstances = Object.create(null);
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports.__esModule = true;
exports.isCompositeComponent = isCompositeComponent;
exports.getInstances = getInstances;
exports.getInternalInstance = getInternalInstance;
exports. = ;
exports.wrapStateless = wrapStateless;
exports.getMountPoint = getMountPoint;
exports.getRootInstance = getRootInstance;
Expand Down Expand Up @@ -65,7 +65,7 @@ function isCompositeComponent(inst) {

function getInstances(component) {
var _public = component,
_private = getInternalInstance(component);
_private = (component);

if (component.getPublicInstance) {
_public = component.getPublicInstance();
Expand All @@ -79,7 +79,7 @@ function getInstances(component) {
return { 'private': _private, 'public': _public };
}

function getInternalInstance(component) {
function (component) {
if (!component) return;

if (component.getPublicInstance) return component;
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"test": "karma start --single-run",
"tdd": "karma start",
"build": "babel src --out-dir lib && cpy ./README.md ./lib",
"toc": "doctoc README.md --github",
"build": "babel src --out-dir lib && npm run toc && cpy ./README.md ./lib",
"release": "release"
},
"repository": {
Expand Down Expand Up @@ -34,10 +35,13 @@
"babel-plugin-object-assign": "^1.2.1",
"chai": "^3.3.0",
"cpy": "^3.4.1",
"doctoc": "^0.15.0",
"isparta": "^4.0.0",
"karma": "^0.13.10",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.2.0",
"karma-cli": "^0.1.0",
"karma-coverage": "^0.5.3",
"karma-mocha": "^0.2.0",
"karma-mocha-reporter": "^1.1.1",
"karma-sinon": "^1.0.4",
Expand All @@ -52,9 +56,10 @@
"webpack": "^1.12.2"
},
"dependencies": {
"bill": "^2.0.0",
"bill": "^2.0.3",
"dom-helpers": "^2.4.0",
"lodash": "^3.10.1",
"promise": "^7.1.1",
"react-addons-test-utils": "^0.14.0-rc1",
"warning": "^2.1.0"
},
Expand Down
40 changes: 17 additions & 23 deletions src/QueryCollection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import common from './common';
import { createNode } from 'bill/node';

import { selector } from 'bill';
import { match, getPublicInstances } from './utils';
import {
isQueryCollection, getPublicInstances
, unwrapAndCreateNode, attachElementsToCollection } from './utils';

import common from './common';

export default function createCollection(ctor) {
let $ = QueryCollection
Expand All @@ -12,35 +15,26 @@ export default function createCollection(ctor) {

let elements = element == null ? [] : [].concat(element);

if (element && $.isQueryCollection(element)) {
if (element && isQueryCollection(element)) {
return new element.constructor(element.get(), element)
}

this._isQueryCollection = true
this.context = lastCollection || this
this.nodes = elements.map(el => createNode(el))
this.length = elements.length
this.root = lastCollection || this

getPublicInstances(this.nodes)
.forEach((el, idx)=> this[idx] = el)
attachElementsToCollection(this, elements)

return ctor.call(this, element, lastCollection)
return ctor.call(this, elements, lastCollection)
}

Object.assign($, {
match,
selector,
s: selector,
isQueryCollection(inst) {
return !!inst._isQueryCollection
}
})

$.fn = $.prototype = {
constructor: $,
}
$.fn = $.prototype = Object.create(common)

common($)
Object.defineProperty($.prototype, 'constructor', {
value: $,
enumerable: false,
writable: true,
configurable: true
})

return $
}
Loading

0 comments on commit 9b40e02

Please sign in to comment.