MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / Component

Function Component

MathBox/mathbox-core.js:6758–6810  ·  view source on GitHub ↗
(node, props1, state1, children1)

Source from the content-addressed store, hash-verified

6756 }
6757 Component = (function() {
6758 function Component(node, props1, state1, children1) {
6759 var bind, k, nextState, v;
6760 this.props = props1 != null ? props1 : {};
6761 this.state = state1 != null ? state1 : null;
6762 this.children = children1 != null ? children1 : null;
6763 bind = function(f, self) {
6764 if (typeof f === 'function') {
6765 return f.bind(self);
6766 } else {
6767 return f;
6768 }
6769 };
6770 for (k in prototype) {
6771 v = prototype[k];
6772 this[k] = bind(v, this);
6773 }
6774 nextState = null;
6775 this.setState = function(state) {
6776 if (nextState == null) {
6777 nextState = state ? nextState != null ? nextState : {} : null;
6778 }
6779 for (k in state) {
6780 v = state[k];
6781 nextState[k] = v;
6782 }
6783 node._COMPONENT_DIRTY = true;
6784 };
6785 this.forceUpdate = function() {
6786 var el, results;
6787 node._COMPONENT_FORCE = node._COMPONENT_DIRTY = true;
6788 el = node;
6789 results = [];
6790 while (el = el.parentNode) {
6791 if (el._COMPONENT) {
6792 results.push(el._COMPONENT_FORCE = true);
6793 } else {
6794 results.push(void 0);
6795 }
6796 }
6797 return results;
6798 };
6799 this.getNextState = function() {
6800 return nextState;
6801 };
6802 this.applyNextState = function() {
6803 var prevState, ref2;
6804 node._COMPONENT_FORCE = node._COMPONENT_DIRTY = false;
6805 prevState = this.state;
6806 ref2 = [null, nextState], nextState = ref2[0], this.state = ref2[1];
6807 return prevState;
6808 };
6809 return;
6810 }
6811
6812 return Component;
6813

Callers

nothing calls this directly

Calls 1

bindFunction · 0.70

Tested by

no test coverage detected