code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
standardReleaser = function (instance) { var Klass = this; !(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : _prodInvariant('25') : void 0; instance.destructor(); if (Klass.instancePool.length < Klass.p...
Static poolers. Several custom versions for each potential number of arguments. A completely generic pooler is easy to implement, but would require accessing the `arguments` object. In each of these, `this` refers to the Class itself, not an instance. If any others are needed, simply add them here, or in their own file...
standardReleaser
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
addPoolingTo = function (CopyConstructor, pooler) { // Casting as any so that flow ignores the actual implementation and trusts // it to match the type we declared var NewKlass = CopyConstructor; NewKlass.instancePool = []; NewKlass.getPooled = pooler || DEFAULT_POOLER; if (!NewKlass.poolSize) { ...
Augments `CopyConstructor` to be a poolable class, augmenting only the class itself (statically) not adding any prototypical fields. Any CopyConstructor you give this may have a `poolSize` property, and will look for a prototypical `destructor` on instances. @param {Function} CopyConstructor Constructor that can be us...
addPoolingTo
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getTextContentAccessor() { if (!contentKey && ExecutionEnvironment.canUseDOM) { // Prefer textContent to innerText because many browsers support both but // SVG <text> elements don't support innerText even when <div> does. contentKey = 'textContent' in document.documentElement ? 'textContent'...
Gets the key used to access text content on a DOM node. @return {?string} Key used to access text content. @internal
getTextContentAccessor
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); }
@param {object} dispatchConfig Configuration used to dispatch this event. @param {string} dispatchMarker Marker identifying the event target. @param {object} nativeEvent Native browser event. @extends {SyntheticUIEvent}
SyntheticCompositionEvent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { if (process.env.NODE_ENV !== 'production') { // these have a getter/setter for warnings delete this.nativeEvent; delete this.preventDefault; delete this.stopPropagation; } this.dispatchConfig = dispatchCo...
Synthetic events are dispatched by event plugins, typically in response to a top-level event delegation handler. These systems should generally use pooling to reduce the frequency of garbage collection. The system should check `isPersistent` to determine whether the event should be released into the pool after being d...
SyntheticEvent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getPooledWarningPropertyDefinition(propName, getVal) { var isFunction = typeof getVal === 'function'; return { configurable: true, set: set, get: get }; function set(val) { var action = isFunction ? 'setting the method' : 'setting the property'; warn(action, 'This is effec...
Helper to nullify syntheticEvent instance properties when destructing @param {object} SyntheticEvent @param {String} propName @return {object} defineProperty object
getPooledWarningPropertyDefinition
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function set(val) { var action = isFunction ? 'setting the method' : 'setting the property'; warn(action, 'This is effectively a no-op'); return val; }
Helper to nullify syntheticEvent instance properties when destructing @param {object} SyntheticEvent @param {String} propName @return {object} defineProperty object
set
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function get() { var action = isFunction ? 'accessing the method' : 'accessing the property'; var result = isFunction ? 'This is a no-op function' : 'This is set to null'; warn(action, result); return getVal; }
Helper to nullify syntheticEvent instance properties when destructing @param {object} SyntheticEvent @param {String} propName @return {object} defineProperty object
get
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function warn(action, result) { var warningCondition = false; process.env.NODE_ENV !== 'production' ? warning(warningCondition, 'This synthetic event is reused for performance reasons. If you\'re seeing this, ' + 'you\'re %s `%s` on a released/nullified synthetic event. %s. ' + 'If you must keep the original ...
Helper to nullify syntheticEvent instance properties when destructing @param {object} SyntheticEvent @param {String} propName @return {object} defineProperty object
warn
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function SyntheticInputEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); }
@param {object} dispatchConfig Configuration used to dispatch this event. @param {string} dispatchMarker Marker identifying the event target. @param {object} nativeEvent Native browser event. @extends {SyntheticUIEvent}
SyntheticInputEvent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function startWatchingForValueChange(target, targetInst) { activeElement = target; activeElementInst = targetInst; activeElementValue = target.value; activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value'); // Not guarded in a canDefineProperty check: IE8 supports...
(For IE <=11) Starts tracking propertychange events on the passed-in element and override the value property so that we can distinguish user events from value changes in JS.
startWatchingForValueChange
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function stopWatchingForValueChange() { if (!activeElement) { return; } // delete restores the original property definition delete activeElement.value; if (activeElement.detachEvent) { activeElement.detachEvent('onpropertychange', handlePropertyChange); } else { activeElement.removeEv...
(For IE <=11) Removes the event listeners from the currently-tracked element, if any exists.
stopWatchingForValueChange
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function handlePropertyChange(nativeEvent) { if (nativeEvent.propertyName !== 'value') { return; } var value = nativeEvent.srcElement.value; if (value === activeElementValue) { return; } activeElementValue = value; manualDispatchChangeEvent(nativeEvent); }
(For IE <=11) Handles a propertychange event, sending a `change` event if the value of the active element has changed.
handlePropertyChange
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getTargetInstForInputEvent(topLevelType, targetInst) { if (topLevelType === 'topInput') { // In modern browsers (i.e., not IE8 or IE9), the input event is exactly // what we want so fall through here and trigger an abstract event return targetInst; } }
If a `change` event should be fired, returns the target's ID.
getTargetInstForInputEvent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function handleEventsForInputEventIE(topLevelType, target, targetInst) { if (topLevelType === 'topFocus') { // In IE8, we can capture almost all .value changes by adding a // propertychange handler and looking for events with propertyName // equal to 'value' // In IE9-11, propertychange fires for...
If a `change` event should be fired, returns the target's ID.
handleEventsForInputEventIE
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getTargetInstForInputEventIE(topLevelType, targetInst) { if (topLevelType === 'topSelectionChange' || topLevelType === 'topKeyUp' || topLevelType === 'topKeyDown') { // On the selectionchange event, the target is just document which isn't // helpful for us so just check activeElement instead. ...
If a `change` event should be fired, returns the target's ID.
getTargetInstForInputEventIE
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function mountOrderComparator(c1, c2) { return c1._mountOrder - c2._mountOrder; }
Array comparator for ReactComponents by mount ordering. @param {ReactComponent} c1 first component you're comparing @param {ReactComponent} c2 second component you're comparing @return {number} Return value usable by Array.prototype.sort().
mountOrderComparator
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function runBatchedUpdates(transaction) { var len = transaction.dirtyComponentsLength; !(len === dirtyComponents.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected flush transaction\'s stored dirty-components length (%s) to match dirty-components array length (%s).', len, dirtyComponents...
Array comparator for ReactComponents by mount ordering. @param {ReactComponent} c1 first component you're comparing @param {ReactComponent} c2 second component you're comparing @return {number} Return value usable by Array.prototype.sort().
runBatchedUpdates
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
flushBatchedUpdates = function () { // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents // array and perform any updates enqueued by mount-ready handlers (i.e., // componentDidUpdate) but we need to check here too in order to catch // updates enqueued by setState callbacks and asap cal...
Array comparator for ReactComponents by mount ordering. @param {ReactComponent} c1 first component you're comparing @param {ReactComponent} c2 second component you're comparing @return {number} Return value usable by Array.prototype.sort().
flushBatchedUpdates
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function enqueueUpdate(component) { ensureInjected(); // Various parts of our code (such as ReactCompositeComponent's // _renderValidatedComponent) assume that calls to render aren't nested; // verify that that's the case. (This is called by each top-level update // function, like setState, forceUpdate,...
Mark a component as needing a rerender, adding an optional callback to a list of functions which will be executed once the rerender occurs.
enqueueUpdate
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function asap(callback, context) { !batchingStrategy.isBatchingUpdates ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context whereupdates are not being batched.') : _prodInvariant('125') : void 0; asapCallbackQueue.enqueue(callback, context); ...
Enqueue a callback to be run at the end of the current batching cycle. Throws if no updates are currently being performed.
asap
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function CallbackQueue(arg) { _classCallCheck(this, CallbackQueue); this._callbacks = null; this._contexts = null; this._arg = arg; }
A specialized pseudo-event module to help keep track of components waiting to be notified when their DOM representations are available for use. This implements `PooledClass`, so you should never need to instantiate this. Instead, use `CallbackQueue.getPooled()`. @class ReactMountReady @implements PooledClass @interna...
CallbackQueue
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function attachRefs() { ReactRef.attachRefs(this, this._currentElement); }
Helper to call ReactRef.attachRefs with this composite component, split out to avoid allocations in the transaction mount-ready queue.
attachRefs
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function isValidOwner(object) { return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function'); }
@param {?object} object @return {boolean} True if `object` is a valid owner. @final
isValidOwner
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getEventTarget(nativeEvent) { var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 if (target.correspondingUseElement) { target = target.correspondingUseElement; } // Safari may fire events on text nodes (Node.TEXT_NODE is 3). ...
Gets the target node from a native browser event by accounting for inconsistencies in browser DOM APIs. @param {object} nativeEvent Native browser event. @return {DOMEventTarget} Target node.
getEventTarget
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function isTextInputElement(elem) { var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); if (nodeName === 'input') { return !!supportedInputTypes[elem.type]; } if (nodeName === 'textarea') { return true; } return false; }
@see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
isTextInputElement
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); }
@param {object} dispatchConfig Configuration used to dispatch this event. @param {string} dispatchMarker Marker identifying the event target. @param {object} nativeEvent Native browser event. @extends {SyntheticUIEvent}
SyntheticMouseEvent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); }
@param {object} dispatchConfig Configuration used to dispatch this event. @param {string} dispatchMarker Marker identifying the event target. @param {object} nativeEvent Native browser event. @extends {SyntheticEvent}
SyntheticUIEvent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function modifierStateGetter(keyArg) { var syntheticEvent = this; var nativeEvent = syntheticEvent.nativeEvent; if (nativeEvent.getModifierState) { return nativeEvent.getModifierState(keyArg); } var keyProp = modifierKeyToProp[keyArg]; return keyProp ? !!nativeEvent[keyProp] : false; }
Translation from modifier key to the associated property in the event. @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
modifierStateGetter
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getEventModifierState(nativeEvent) { return modifierStateGetter; }
Translation from modifier key to the associated property in the event. @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
getEventModifierState
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function insertLazyTreeChildAt(parentNode, childTree, referenceNode) { DOMLazyTree.insertTreeBefore(parentNode, childTree, referenceNode); }
Inserts `childNode` as a child of `parentNode` at the `index`. @param {DOMElement} parentNode Parent node in which to insert. @param {DOMElement} childNode Child node to insert. @param {number} index Index at which to insert the child. @internal
insertLazyTreeChildAt
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function moveChild(parentNode, childNode, referenceNode) { if (Array.isArray(childNode)) { moveDelimitedText(parentNode, childNode[0], childNode[1], referenceNode); } else { insertChildAt(parentNode, childNode, referenceNode); } }
Inserts `childNode` as a child of `parentNode` at the `index`. @param {DOMElement} parentNode Parent node in which to insert. @param {DOMElement} childNode Child node to insert. @param {number} index Index at which to insert the child. @internal
moveChild
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function removeChild(parentNode, childNode) { if (Array.isArray(childNode)) { var closingComment = childNode[1]; childNode = childNode[0]; removeDelimitedText(parentNode, childNode, closingComment); parentNode.removeChild(closingComment); } parentNode.removeChild(childNode); }
Inserts `childNode` as a child of `parentNode` at the `index`. @param {DOMElement} parentNode Parent node in which to insert. @param {DOMElement} childNode Child node to insert. @param {number} index Index at which to insert the child. @internal
removeChild
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function moveDelimitedText(parentNode, openingComment, closingComment, referenceNode) { var node = openingComment; while (true) { var nextNode = node.nextSibling; insertChildAt(parentNode, node, referenceNode); if (node === closingComment) { break; } node = nextNode; } }
Inserts `childNode` as a child of `parentNode` at the `index`. @param {DOMElement} parentNode Parent node in which to insert. @param {DOMElement} childNode Child node to insert. @param {number} index Index at which to insert the child. @internal
moveDelimitedText
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function removeDelimitedText(parentNode, startNode, closingComment) { while (true) { var node = startNode.nextSibling; if (node === closingComment) { // The closing comment is removed by ReactMultiChild. break; } else { parentNode.removeChild(node); } } }
Inserts `childNode` as a child of `parentNode` at the `index`. @param {DOMElement} parentNode Parent node in which to insert. @param {DOMElement} childNode Child node to insert. @param {number} index Index at which to insert the child. @internal
removeDelimitedText
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function replaceDelimitedText(openingComment, closingComment, stringText) { var parentNode = openingComment.parentNode; var nodeAfterComment = openingComment.nextSibling; if (nodeAfterComment === closingComment) { // There are no text nodes between the opening and closing comments; insert // a new on...
Inserts `childNode` as a child of `parentNode` at the `index`. @param {DOMElement} parentNode Parent node in which to insert. @param {DOMElement} childNode Child node to insert. @param {number} index Index at which to insert the child. @internal
replaceDelimitedText
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function insertTreeChildren(tree) { if (!enableLazy) { return; } var node = tree.node; var children = tree.children; if (children.length) { for (var i = 0; i < children.length; i++) { insertTreeBefore(node, children[i], null); } } else if (tree.html != null) { setInnerHTML(n...
In IE (8-11) and Edge, appending nodes with no children is dramatically faster than appending a full subtree, so we essentially queue up the .appendChild calls here and apply them so each node is added to its parent before any children are added. In other browsers, doing so is slower or neutral compared to the other o...
insertTreeChildren
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function replaceChildWithTree(oldNode, newTree) { oldNode.parentNode.replaceChild(newTree.node, oldNode); insertTreeChildren(newTree); }
In IE (8-11) and Edge, appending nodes with no children is dramatically faster than appending a full subtree, so we essentially queue up the .appendChild calls here and apply them so each node is added to its parent before any children are added. In other browsers, doing so is slower or neutral compared to the other o...
replaceChildWithTree
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function queueChild(parentTree, childTree) { if (enableLazy) { parentTree.children.push(childTree); } else { parentTree.node.appendChild(childTree.node); } }
In IE (8-11) and Edge, appending nodes with no children is dramatically faster than appending a full subtree, so we essentially queue up the .appendChild calls here and apply them so each node is added to its parent before any children are added. In other browsers, doing so is slower or neutral compared to the other o...
queueChild
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function queueHTML(tree, html) { if (enableLazy) { tree.html = html; } else { setInnerHTML(tree.node, html); } }
In IE (8-11) and Edge, appending nodes with no children is dramatically faster than appending a full subtree, so we essentially queue up the .appendChild calls here and apply them so each node is added to its parent before any children are added. In other browsers, doing so is slower or neutral compared to the other o...
queueHTML
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function queueText(tree, text) { if (enableLazy) { tree.text = text; } else { setTextContent(tree.node, text); } }
In IE (8-11) and Edge, appending nodes with no children is dramatically faster than appending a full subtree, so we essentially queue up the .appendChild calls here and apply them so each node is added to its parent before any children are added. In other browsers, doing so is slower or neutral compared to the other o...
queueText
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function toString() { return this.node.nodeName; }
In IE (8-11) and Edge, appending nodes with no children is dramatically faster than appending a full subtree, so we essentially queue up the .appendChild calls here and apply them so each node is added to its parent before any children are added. In other browsers, doing so is slower or neutral compared to the other o...
toString
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function DOMLazyTree(node) { return { node: node, children: [], html: null, text: null, toString: toString }; }
In IE (8-11) and Edge, appending nodes with no children is dramatically faster than appending a full subtree, so we essentially queue up the .appendChild calls here and apply them so each node is added to its parent before any children are added. In other browsers, doing so is slower or neutral compared to the other o...
DOMLazyTree
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
createMicrosoftUnsafeLocalFunction = function (func) { if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { return function (arg0, arg1, arg2, arg3) { MSApp.execUnsafeLocalFunction(function () { return func(arg0, arg1, arg2, arg3); }); }; } else { return func;...
Create a function which has 'unsafe' privileges (required by windows8 apps)
createMicrosoftUnsafeLocalFunction
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
setTextContent = function (node, text) { if (text) { var firstChild = node.firstChild; if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) { firstChild.nodeValue = text; return; } } node.textContent = text; }
Set the textContent property of a node, ensuring that whitespace is preserved even in IE8. innerText is a poor substitute for textContent and, among many issues, inserts <br> instead of the literal newline chars. innerHTML behaves as it should. @param {DOMElement} node @param {string} text @internal
setTextContent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function escapeHtml(string) { var str = '' + string; var match = matchHtmlRegExp.exec(str); if (!match) { return str; } var escape; var html = ''; var index = 0; var lastIndex = 0; for (index = match.index; index < str.length; index++) { switch (str.charCodeAt(index)) { ca...
Escape special characters in the given string of html. @param {string} string The string to escape for inserting into HTML @return {string} @public
escapeHtml
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function escapeTextContentForBrowser(text) { if (typeof text === 'boolean' || typeof text === 'number') { // this shortcircuit helps perf for types that we know will never have // special characters, especially given that this function is used often // for numeric dom ids. return '' + text; } ...
Escapes text to prevent scripting attacks. @param {*} text Text value to escape. @return {string} An escaped string.
escapeTextContentForBrowser
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getNodeName(markup) { var nodeNameMatch = markup.match(nodeNamePattern); return nodeNameMatch && nodeNameMatch[1].toLowerCase(); }
Extracts the `nodeName` of the first element in a string of markup. @param {string} markup String of markup. @return {?string} Node name of the supplied markup.
getNodeName
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function createNodesFromMarkup(markup, handleScript) { var node = dummyNode; !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : void 0; var nodeName = getNodeName(markup); var wrap = nodeName && getMarkupWrap(nodeName)...
Creates an array containing the nodes rendered from the supplied markup. The optionally supplied `handleScript` function will be invoked once for each <script> element that is rendered. If no `handleScript` function is supplied, an exception is thrown if any <script> elements are rendered. @param {string} markup A str...
createNodesFromMarkup
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function toArray(obj) { var length = obj.length; // Some browsers builtin objects can report typeof 'function' (e.g. NodeList // in old versions of Safari). !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: ...
Convert array-like objects to arrays. This API assumes the caller knows the contents of the data type. For less well defined inputs use createArrayFromMixed. @param {object|function|filelist} obj @return {array}
toArray
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function hasArrayNature(obj) { return ( // not null/false !!obj && ( // arrays are objects, NodeLists are functions in Safari typeof obj == 'object' || typeof obj == 'function') && // quacks like an array 'length' in obj && // not window !('setInterval' in obj) && // no D...
Perform a heuristic test to determine if an object is "array-like". A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" Joshu replied: "Mu." This function determines if its argument has "array nature": it returns true if the argument is an actual array, an `arguments' object, or an HTMLCollection (e.g. n...
hasArrayNature
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function createArrayFromMixed(obj) { if (!hasArrayNature(obj)) { return [obj]; } else if (Array.isArray(obj)) { return obj.slice(); } else { return toArray(obj); } }
Ensure that the argument is an array by wrapping it in an array if it is not. Creates a copy of the argument if it is already an array. This is mostly useful idiomatically: var createArrayFromMixed = require('createArrayFromMixed'); function takesOneOrMoreThings(things) { things = createArrayFromMixed(things...
createArrayFromMixed
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getMarkupWrap(nodeName) { !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : void 0; if (!markupWrap.hasOwnProperty(nodeName)) { nodeName = '*'; } if (!shouldWrap.hasOwnProperty(nodeName)) { if (nodeName ===...
Gets the markup wrap configuration for the supplied `nodeName`. NOTE: This lazily detects which wraps are necessary for the current browser. @param {string} nodeName Lowercase `nodeName`. @return {?array} Markup wrap configuration, if applicable.
getMarkupWrap
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function assertValidProps(component, props) { if (!props) { return; } // Note the use of `==` which checks for null or undefined. if (voidElementTags[component._tag]) { !(props.children == null && props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s...
@param {object} component @param {?object} props
assertValidProps
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function enqueuePutListener(inst, registrationName, listener, transaction) { if (transaction instanceof ReactServerRenderingTransaction) { return; } if (process.env.NODE_ENV !== 'production') { // IE8 has no API for event capturing and the `onScroll` event doesn't // bubble. process.env.NOD...
@param {object} component @param {?object} props
enqueuePutListener
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function putListener() { var listenerToPut = this; EventPluginHub.putListener(listenerToPut.inst, listenerToPut.registrationName, listenerToPut.listener); }
@param {object} component @param {?object} props
putListener
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function inputPostMount() { var inst = this; ReactDOMInput.postMountWrapper(inst); }
@param {object} component @param {?object} props
inputPostMount
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function textareaPostMount() { var inst = this; ReactDOMTextarea.postMountWrapper(inst); }
@param {object} component @param {?object} props
textareaPostMount
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function optionPostMount() { var inst = this; ReactDOMOption.postMountWrapper(inst); }
@param {object} component @param {?object} props
optionPostMount
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function trapBubbledEventsLocal() { var inst = this; // If a component renders to null or if another component fatals and causes // the state of the tree to be corrupted, `node` here can be null. !inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Must be mounted to trap events') :...
@param {object} component @param {?object} props
trapBubbledEventsLocal
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function validateDangerousTag(tag) { if (!hasOwnProperty.call(validatedTagCache, tag)) { !VALID_TAG_REGEX.test(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Invalid tag: %s', tag) : _prodInvariant('65', tag) : void 0; validatedTagCache[tag] = true; } }
@param {object} component @param {?object} props
validateDangerousTag
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function isCustomComponent(tagName, props) { return tagName.indexOf('-') >= 0 || props.is != null; }
@param {object} component @param {?object} props
isCustomComponent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function ReactDOMComponent(element) { var tag = element.type; validateDangerousTag(tag); this._currentElement = element; this._tag = tag.toLowerCase(); this._namespaceURI = null; this._renderedChildren = null; this._previousStyle = null; this._previousStyleCopy = null; this._hostNode = null; ...
Creates a new React class that is idempotent and capable of containing other React components. It accepts event listeners and DOM properties that are valid according to `DOMProperty`. - Event listeners: `onClick`, `onMouseDown`, etc. - DOM properties: `className`, `name`, `title`, etc. The `style` property function...
ReactDOMComponent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function focusNode(node) { // IE8 can throw "Can't move focus to the control because it is invisible, // not enabled, or of a type that does not accept the focus." for all kinds of // reasons that are too expensive and fragile to test. try { node.focus(); } catch (e) {} }
@param {DOMElement} node input/textarea to focus
focusNode
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
warnValidStyle = function (name, value, component) { var owner; if (component) { owner = component._currentElement._owner; } if (name.indexOf('-') > -1) { warnHyphenatedStyleName(name, owner); } else if (badVendoredStyleNamePattern.test(name)) { warnBadVendoredStyleName(nam...
@param {string} name @param {*} value @param {ReactDOMComponent} component
warnValidStyle
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function prefixKey(prefix, key) { return prefix + key.charAt(0).toUpperCase() + key.substring(1); }
@param {string} prefix vendor-specific prefix, eg: Webkit @param {string} key style name, eg: transitionDuration @return {string} style name prefixed with `prefix`, properly camelCased, eg: WebkitTransitionDuration
prefixKey
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function camelize(string) { return string.replace(_hyphenPattern, function (_, character) { return character.toUpperCase(); }); }
Camelcases a hyphenated string, for example: > camelize('background-color') < "backgroundColor" @param {string} string @return {string}
camelize
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function dangerousStyleValue(name, value, component) { // Note that we've removed escapeTextForBrowser() calls here since the // whole string will be escaped when the attribute is injected into // the markup. If you provide unsafe user data here they can inject // arbitrary CSS which may be problematic (I c...
Convert a value into the proper css writable value. The style name `name` should be logical (no hyphens), as specified in `CSSProperty.isUnitlessNumber`. @param {string} name CSS property name such as `topMargin`. @param {*} value CSS property value such as `10px`. @param {ReactDOMComponent} component @return {string}...
dangerousStyleValue
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function hyphenateStyleName(string) { return hyphenate(string).replace(msPattern, '-ms-'); }
Hyphenates a camelcased CSS property name, for example: > hyphenateStyleName('backgroundColor') < "background-color" > hyphenateStyleName('MozTransition') < "-moz-transition" > hyphenateStyleName('msTransition') < "-ms-transition" As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix...
hyphenateStyleName
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function hyphenate(string) { return string.replace(_uppercasePattern, '-$1').toLowerCase(); }
Hyphenates a camelcased string, for example: > hyphenate('backgroundColor') < "background-color" For CSS style names, use `hyphenateStyleName` instead which works properly with all vendor prefixes, including `ms`. @param {string} string @return {string}
hyphenate
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function memoizeStringOnly(callback) { var cache = {}; return function (string) { if (!cache.hasOwnProperty(string)) { cache[string] = callback.call(this, string); } return cache[string]; }; }
Memoizes the return value of a function that accepts one string argument.
memoizeStringOnly
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function quoteAttributeValueForBrowser(value) { return '"' + escapeTextContentForBrowser(value) + '"'; }
Escapes attribute value to prevent scripting attacks. @param {*} value Value to escape. @return {string} An escaped string.
quoteAttributeValueForBrowser
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getListeningForDocument(mountAt) { // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` // directly. if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { mountAt[topListenersIDKey] = reactTopListenersCounter++; alreadyListeningTo[mountAt[topListenersIDK...
To ensure no conflicts with other potential React instances on the page
getListeningForDocument
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function makePrefixMap(styleProp, eventName) { var prefixes = {}; prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); prefixes['Webkit' + styleProp] = 'webkit' + eventName; prefixes['Moz' + styleProp] = 'moz' + eventName; prefixes['ms' + styleProp] = 'MS' + eventName; prefixes['O' + stylePro...
Generate a mapping of standard vendor prefixes using the defined style property and event name. @param {string} styleProp @param {string} eventName @returns {object}
makePrefixMap
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getVendorPrefixedEventName(eventName) { if (prefixedEventNames[eventName]) { return prefixedEventNames[eventName]; } else if (!vendorPrefixes[eventName]) { return eventName; } var prefixMap = vendorPrefixes[eventName]; for (var styleProp in prefixMap) { if (prefixMap.hasOwnPrope...
Attempts to determine the correct vendor prefixed event name. @param {string} eventName @returns {string}
getVendorPrefixedEventName
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function _handleChange(event) { var props = this._currentElement.props; var returnValue = LinkedValueUtils.executeOnChange(props, event); // Here we use asap to wait until all updates have propagated, which // is important when using controlled components within layers: // https://github.com/facebook/r...
Implements an <input> host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not ...
_handleChange
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function checkSelectPropTypes(inst, props) { var owner = inst._currentElement._owner; LinkedValueUtils.checkPropTypes('select', props, owner); if (props.valueLink !== undefined && !didWarnValueLink) { process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `select` is deprecated; set ...
Validation function for `value` and `defaultValue`. @private
checkSelectPropTypes
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function updateOptions(inst, multiple, propValue) { var selectedValue, i; var options = ReactDOMComponentTree.getNodeFromInstance(inst).options; if (multiple) { selectedValue = {}; for (i = 0; i < propValue.length; i++) { selectedValue['' + propValue[i]] = true; } for (i = 0; i < op...
@param {ReactDOMComponent} inst @param {boolean} multiple @param {*} propValue A stringable (with `multiple`, a list of stringables). @private
updateOptions
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function _handleChange(event) { var props = this._currentElement.props; var returnValue = LinkedValueUtils.executeOnChange(props, event); if (this._rootNodeID) { this._wrapperState.pendingUpdate = true; } ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this); return returnValue; }
Implements a <select> host component that allows optionally setting the props `value` and `defaultValue`. If `multiple` is false, the prop must be a stringable. If `multiple` is true, the prop must be an array of stringables. If `value` is not supplied (or null/undefined), user actions that change the selected option ...
_handleChange
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function _handleChange(event) { var props = this._currentElement.props; var returnValue = LinkedValueUtils.executeOnChange(props, event); ReactUpdates.asap(forceUpdateIfMounted, this); return returnValue; }
Implements a <textarea> host component that allows setting `value`, and `defaultValue`. This differs from the traditional DOM API because value is usually set as PCDATA children. If `value` is not supplied (or null/undefined), user actions that affect the value will trigger updates to the element. If `value` is suppl...
_handleChange
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function makeInsertMarkup(markup, afterNode, toIndex) { // NOTE: Null values reduce hidden classes. return { type: 'INSERT_MARKUP', content: markup, fromIndex: null, fromNode: null, toIndex: toIndex, afterNode: afterNode }; }
Make an update for markup to be rendered and inserted at a supplied index. @param {string} markup Markup that renders into an element. @param {number} toIndex Destination index. @private
makeInsertMarkup
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function makeMove(child, afterNode, toIndex) { // NOTE: Null values reduce hidden classes. return { type: 'MOVE_EXISTING', content: null, fromIndex: child._mountIndex, fromNode: ReactReconciler.getHostNode(child), toIndex: toIndex, afterNode: afterNode }; }
Make an update for moving an existing element to another index. @param {number} fromIndex Source index of the existing element. @param {number} toIndex Destination index of the element. @private
makeMove
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function makeRemove(child, node) { // NOTE: Null values reduce hidden classes. return { type: 'REMOVE_NODE', content: null, fromIndex: child._mountIndex, fromNode: node, toIndex: null, afterNode: null }; }
Make an update for removing an element at an index. @param {number} fromIndex Index of the element to remove. @private
makeRemove
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function makeSetMarkup(markup) { // NOTE: Null values reduce hidden classes. return { type: 'SET_MARKUP', content: markup, fromIndex: null, fromNode: null, toIndex: null, afterNode: null }; }
Make an update for setting the markup of a node. @param {string} markup Markup that renders into an element. @private
makeSetMarkup
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function makeTextContent(textContent) { // NOTE: Null values reduce hidden classes. return { type: 'TEXT_CONTENT', content: textContent, fromIndex: null, fromNode: null, toIndex: null, afterNode: null }; }
Make an update for setting the text content. @param {string} textContent Text content to set. @private
makeTextContent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function enqueue(queue, update) { if (update) { queue = queue || []; queue.push(update); } return queue; }
Push an update, if any, onto the queue. Creates a new queue if none is passed and always returns the queue. Mutative.
enqueue
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function isInternalComponentType(type) { return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function'; }
Check if the type reference is a known internal type. I.e. not a user provided composite type. @param {function} type @return {boolean} Returns true if this is a valid internal type.
isInternalComponentType
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function instantiateReactComponent(node, shouldHaveDebugID) { var instance; if (node === null || node === false) { instance = ReactEmptyComponent.create(instantiateReactComponent); } else if (typeof node === 'object') { var element = node; var type = element.type; if (typeof type !== 'func...
Given a ReactNode, create an instance that will actually be mounted. @param {ReactNode} node @param {boolean} shouldHaveDebugID @return {object} A new instance of the element's constructor. @protected
instantiateReactComponent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function checkReactTypeSpec(typeSpecs, values, location, componentName, element, debugID) { for (var typeSpecName in typeSpecs) { if (typeSpecs.hasOwnProperty(typeSpecName)) { var error; // Prop type validation may throw. In case they do, we don't want to // fail the render phase where it d...
Assert that the values match with the type specs. Error messages are memorized and will only be shown once. @param {object} typeSpecs Map of name to a ReactPropType @param {object} values Runtime values that need to be type-checked @param {string} location e.g. "prop", "context", "child context" @param {string} compon...
checkReactTypeSpec
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function shallowEqual(objA, objB) { if (is(objA, objB)) { return true; } if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { return false; } var keysA = Object.keys(objA); var keysB = Object.keys(objB); if (keysA.length !== keysB.length) { ...
Performs equality by iterating through keys on an object and returning false when any key has values which are not strictly equal between the arguments. Returns true when the values of all keys are strictly equal.
shallowEqual
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function shouldUpdateReactComponent(prevElement, nextElement) { var prevEmpty = prevElement === null || prevElement === false; var nextEmpty = nextElement === null || nextElement === false; if (prevEmpty || nextEmpty) { return prevEmpty === nextEmpty; } var prevType = typeof prevElement; var nex...
Given a `prevElement` and `nextElement`, determines if the existing instance should be updated as opposed to being destroyed or replaced by a new instance. Both arguments are elements. This ensures that this logic can operate on stateless trees without any backing instance. @param {?object} prevElement @param {?object...
shouldUpdateReactComponent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function createInternalComponent(element) { !genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : _prodInvariant('111', element.type) : void 0; return new genericComponentClass(element); }
Get a host internal component class for a specific tag. @param {ReactElement} element The element to create. @return {function} The internal class constructor function.
createInternalComponent
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function escape(key) { var escapeRegex = /[=:]/g; var escaperLookup = { '=': '=0', ':': '=2' }; var escapedString = ('' + key).replace(escapeRegex, function (match) { return escaperLookup[match]; }); return '$' + escapedString; }
Escape and wrap key so it is safe to use as a reactid @param {string} key to be escaped. @return {string} the escaped key.
escape
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function unescape(key) { var unescapeRegex = /(=0|=2)/g; var unescaperLookup = { '=0': '=', '=2': ':' }; var keySubstring = key[0] === '.' && key[1] === '$' ? key.substring(2) : key.substring(1); return ('' + keySubstring).replace(unescapeRegex, function (match) { return unescaperLookup[m...
Unescape and unwrap key for human-readable display @param {string} key to unescape. @return {string} the unescaped key.
unescape
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getComponentKey(component, index) { // Do some typechecking here since we call this blindly. We want to ensure // that we don't block potential future ES APIs. if (component && typeof component === 'object' && component.key != null) { // Explicit key return KeyEscapeUtils.escape(component.ke...
Generate a key string that identifies a component within a set. @param {*} component A component that could contain a manual key. @param {number} index Index that is used if a manual key is not provided. @return {string}
getComponentKey
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { var type = typeof children; if (type === 'undefined' || type === 'boolean') { // All of the above are perceived as null. children = null; } if (children === null || type === 'string' || type === 'number' || // ...
@param {?*} children Children tree container. @param {!string} nameSoFar Name of the key path so far. @param {!function} callback Callback to invoke with each child found. @param {?*} traverseContext Used to pass information throughout the traversal process. @return {!number} The number of children in this subtree.
traverseAllChildrenImpl
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function traverseAllChildren(children, callback, traverseContext) { if (children == null) { return 0; } return traverseAllChildrenImpl(children, '', callback, traverseContext); }
Traverses children that are typically specified as `props.children`, but might also be specified through attributes: - `traverseAllChildren(this.props.children, ...)` - `traverseAllChildren(this.props.leftPanelChildren, ...)` The `traverseContext` is an optional argument that is passed through the entire traversal. I...
traverseAllChildren
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function getIteratorFn(maybeIterable) { var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); if (typeof iteratorFn === 'function') { return iteratorFn; } }
Returns the iterator method function contained on the iterable object. Be sure to invoke the function with the iterable as context: var iteratorFn = getIteratorFn(myIterable); if (iteratorFn) { var iterator = iteratorFn.call(myIterable); ... } @param {?object} maybeIterable @return {?function...
getIteratorFn
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID) { // We found a component instance. if (traverseContext && typeof traverseContext === 'object') { var result = traverseContext; var keyUnique = result[name] === undefined; if (process.env.NODE_ENV !== 'production') { ...
@param {function} traverseContext Context passed through traversal. @param {?ReactComponent} child React child component. @param {!string} name String name of key path to child. @param {number=} selfDebugID Optional debugID of the current internal instance.
flattenSingleChildIntoContext
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT
function flattenChildren(children, selfDebugID) { if (children == null) { return children; } var result = {}; if (process.env.NODE_ENV !== 'production') { traverseAllChildren(children, function (traverseContext, child, name) { return flattenSingleChildIntoContext(traverseContext, child, na...
Flattens children that are typically specified as `props.children`. Any null children will not be included in the resulting object. @return {!object} flattened children keyed by name.
flattenChildren
javascript
stitchfix/pyxley
tests/app/static/bundle.js
https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js
MIT