MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / Component

Function Component

MathBox/mathbox-bundle.js:53443–53495  ·  view source on GitHub ↗
(node, props1, state1, children1)

Source from the content-addressed store, hash-verified

53441 }
53442 Component = (function() {
53443 function Component(node, props1, state1, children1) {
53444 var bind, k, nextState, v;
53445 this.props = props1 != null ? props1 : {};
53446 this.state = state1 != null ? state1 : null;
53447 this.children = children1 != null ? children1 : null;
53448 bind = function(f, self) {
53449 if (typeof f === 'function') {
53450 return f.bind(self);
53451 } else {
53452 return f;
53453 }
53454 };
53455 for (k in prototype) {
53456 v = prototype[k];
53457 this[k] = bind(v, this);
53458 }
53459 nextState = null;
53460 this.setState = function(state) {
53461 if (nextState == null) {
53462 nextState = state ? nextState != null ? nextState : {} : null;
53463 }
53464 for (k in state) {
53465 v = state[k];
53466 nextState[k] = v;
53467 }
53468 node._COMPONENT_DIRTY = true;
53469 };
53470 this.forceUpdate = function() {
53471 var el, results;
53472 node._COMPONENT_FORCE = node._COMPONENT_DIRTY = true;
53473 el = node;
53474 results = [];
53475 while (el = el.parentNode) {
53476 if (el._COMPONENT) {
53477 results.push(el._COMPONENT_FORCE = true);
53478 } else {
53479 results.push(void 0);
53480 }
53481 }
53482 return results;
53483 };
53484 this.getNextState = function() {
53485 return nextState;
53486 };
53487 this.applyNextState = function() {
53488 var prevState, ref2;
53489 node._COMPONENT_FORCE = node._COMPONENT_DIRTY = false;
53490 prevState = this.state;
53491 ref2 = [null, nextState], nextState = ref2[0], this.state = ref2[1];
53492 return prevState;
53493 };
53494 return;
53495 }
53496
53497 return Component;
53498

Callers

nothing calls this directly

Calls 1

bindFunction · 0.70

Tested by

no test coverage detected