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 |
---|---|---|---|---|---|---|---|
function isStartish(topLevelType) {
return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart';
} | Dispatch the event to the listener.
@param {SyntheticEvent} event SyntheticEvent to handle
@param {boolean} simulated If the event is simulated (changes exn behavior)
@param {function} listener Application-level callback
@param {*} inst Internal component instance | isStartish | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function executeDispatch(event, simulated, listener, inst) {
var type = event.type || 'unknown-event';
event.currentTarget = EventPluginUtils.getNodeFromInstance(inst);
if (simulated) {
ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event);
} else {
ReactErrorUtils.invokeGuardedCallback(type, listener, event);
}
event.currentTarget = null;
} | Standard/simple iteration through an event's collected dispatches. | executeDispatch | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function executeDispatchesInOrder(event, simulated) {
var dispatchListeners = event._dispatchListeners;
var dispatchInstances = event._dispatchInstances;
if (process.env.NODE_ENV !== 'production') {
validateEventDispatches(event);
}
if (Array.isArray(dispatchListeners)) {
for (var i = 0; i < dispatchListeners.length; i++) {
if (event.isPropagationStopped()) {
break;
}
// Listeners and Instances are two parallel arrays that are always in sync.
executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]);
}
} else if (dispatchListeners) {
executeDispatch(event, simulated, dispatchListeners, dispatchInstances);
}
event._dispatchListeners = null;
event._dispatchInstances = null;
} | Standard/simple iteration through an event's collected dispatches, but stops
at the first dispatch execution returning true, and returns that id.
@return {?string} id of the first dispatch execution who's listener returns
true, or null if no listener returned true. | executeDispatchesInOrder | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function executeDispatchesInOrderStopAtTrue(event) {
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
event._dispatchInstances = null;
event._dispatchListeners = null;
return ret;
} | Execution of a "direct" dispatch - there must be at most one dispatch
accumulated on the event or it is considered an error. It doesn't really make
sense for an event with multiple dispatches (bubbled) to keep track of the
return values at each dispatch execution, but it does tend to make sense when
dealing with "direct" dispatches.
@return {*} The return value of executing the single dispatch. | executeDispatchesInOrderStopAtTrue | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function executeDirectDispatch(event) {
if (process.env.NODE_ENV !== 'production') {
validateEventDispatches(event);
}
var dispatchListener = event._dispatchListeners;
var dispatchInstance = event._dispatchInstances;
!!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : _prodInvariant('103') : void 0;
event.currentTarget = dispatchListener ? EventPluginUtils.getNodeFromInstance(dispatchInstance) : null;
var res = dispatchListener ? dispatchListener(event) : null;
event.currentTarget = null;
event._dispatchListeners = null;
event._dispatchInstances = null;
return res;
} | General utilities that are useful in creating custom Event Plugins. | executeDirectDispatch | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function hasDispatches(event) {
return !!event._dispatchListeners;
} | General utilities that are useful in creating custom Event Plugins. | hasDispatches | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function invokeGuardedCallback(name, func, a) {
try {
func(a);
} catch (x) {
if (caughtError === null) {
caughtError = x;
}
}
} | To help development we can get better devtools integration by simulating a
real browser event. | invokeGuardedCallback | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
printWarning = function printWarning(format) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
} | Similar to invariant but only logs a warning if the condition is not met.
This can be used to log issues in development environments in critical
paths. Removing the logging code for production environments will keep the
same logic and follow the same code paths. | printWarning | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function forEachAccumulated(arr, cb, scope) {
if (Array.isArray(arr)) {
arr.forEach(cb, scope);
} else if (arr) {
cb.call(scope, arr);
}
} | Simple, lightweight module assisting with the detection and context of
Worker. Helps avoid circular dependencies and allows code to reason about
whether or not they are in a Worker, even if they never include the main
`ReactWorker` dependency. | forEachAccumulated | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function FallbackCompositionState(root) {
this._root = root;
this._startText = this.getText();
this._fallbackText = null;
} | Determine the differing substring between the initially stored
text content and the current content.
@return {string} | FallbackCompositionState | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
oneArgumentPooler = function (copyFieldsFrom) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, copyFieldsFrom);
return instance;
} else {
return new Klass(copyFieldsFrom);
}
} | 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 files. | oneArgumentPooler | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
twoArgumentPooler = function (a1, a2) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2);
return instance;
} else {
return new Klass(a1, a2);
}
} | 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 files. | twoArgumentPooler | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
threeArgumentPooler = function (a1, a2, a3) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2, a3);
return instance;
} else {
return new Klass(a1, a2, a3);
}
} | 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 files. | threeArgumentPooler | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
fourArgumentPooler = function (a1, a2, a3, a4) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2, a3, a4);
return instance;
} else {
return new Klass(a1, a2, a3, a4);
}
} | 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 used to reset.
@param {Function} pooler Customizable pooler. | fourArgumentPooler | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
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.poolSize) {
Klass.instancePool.push(instance);
}
} | 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 used to reset.
@param {Function} pooler Customizable pooler. | standardReleaser | 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' : 'innerText';
}
return contentKey;
} | @interface Event
@see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents | getTextContentAccessor | 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 = dispatchConfig;
this._targetInst = targetInst;
this.nativeEvent = nativeEvent;
var Interface = this.constructor.Interface;
for (var propName in Interface) {
if (!Interface.hasOwnProperty(propName)) {
continue;
}
if (process.env.NODE_ENV !== 'production') {
delete this[propName]; // this has a getter/setter for warnings
}
var normalize = Interface[propName];
if (normalize) {
this[propName] = normalize(nativeEvent);
} else {
if (propName === 'target') {
this.target = nativeEventTarget;
} else {
this[propName] = nativeEvent[propName];
}
}
}
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
if (defaultPrevented) {
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
} else {
this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
}
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
return this;
} | 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 dispatched. Users that
need a persisted event should invoke `persist`.
Synthetic events (and subclasses) implement the DOM Level 3 Events API by
normalizing browser quirks. Subclasses do not necessarily have to implement a
DOM interface; custom application-specific events can also subclass this.
@param {object} dispatchConfig Configuration used to dispatch this event.
@param {*} targetInst Marker identifying the event target.
@param {object} nativeEvent Native browser event.
@param {DOMEventTarget} nativeEventTarget Target node. | SyntheticEvent | 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 synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
} | @interface Event
@see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
/#events-inputevents | warn | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getTargetInstForChangeEvent(topLevelType, targetInst) {
if (topLevelType === 'topChange') {
return targetInst;
}
} | (For IE <=11) Replacement getter/setter for the `value` property that gets
set on the active element. | getTargetInstForChangeEvent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function handleEventsForChangeEventIE8(topLevelType, target, targetInst) {
if (topLevelType === 'topFocus') {
// stopWatching() should be a noop here but we call it just in case we
// missed a blur event somehow.
stopWatchingForChangeEventIE8();
startWatchingForChangeEventIE8(target, targetInst);
} else if (topLevelType === 'topBlur') {
stopWatchingForChangeEventIE8();
}
} | (For IE <=11) Replacement getter/setter for the `value` property that gets
set on the active element. | handleEventsForChangeEventIE8 | 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 defineProperty only
// on DOM elements
Object.defineProperty(activeElement, 'value', newValueProp);
if (activeElement.attachEvent) {
activeElement.attachEvent('onpropertychange', handlePropertyChange);
} else {
activeElement.addEventListener('propertychange', handlePropertyChange, false);
}
} | (For IE <=11) Removes the event listeners from the currently-tracked element,
if any exists. | 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.removeEventListener('propertychange', handlePropertyChange, false);
}
activeElement = null;
activeElementInst = null;
activeElementValue = null;
activeElementValueProp = null;
} | If a `change` event should be fired, returns the target's ID. | 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);
} | If a `change` event should be fired, returns the target's ID. | 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 most input events but is buggy and
// doesn't fire when text is deleted, but conveniently, selectionchange
// appears to fire in all of the remaining cases so we catch those and
// forward the event if the value has changed
// In either case, we don't want to call the event handler if the value
// is changed from JS so we redefine a setter for `.value` that updates
// our activeElementValue variable, allowing us to ignore those changes
//
// stopWatching() should be a noop here but we call it just in case we
// missed a blur event somehow.
stopWatchingForValueChange();
startWatchingForValueChange(target, targetInst);
} else if (topLevelType === 'topBlur') {
stopWatchingForValueChange();
}
} | 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 shouldUseClickEvent(elem) {
// Use the `click` event to detect changes to checkbox and radio inputs.
// This approach works across all browsers, whereas `change` does not fire
// until `blur` in IE8.
return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
} | This plugin creates an `onChange` event that normalizes change events
across form elements. This event fires at a time when it's possible to
change the element's value without seeing a flicker.
Supported elements are:
- input (see `isTextInputElement`)
- textarea
- select | shouldUseClickEvent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getTargetInstForClickEvent(topLevelType, targetInst) {
if (topLevelType === 'topClick') {
return targetInst;
}
} | This plugin creates an `onChange` event that normalizes change events
across form elements. This event fires at a time when it's possible to
change the element's value without seeing a flicker.
Supported elements are:
- input (see `isTextInputElement`)
- textarea
- select | getTargetInstForClickEvent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function batchedUpdates(callback, a, b, c, d, e) {
ensureInjected();
return batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
} | 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(). | batchedUpdates | 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.length) : _prodInvariant('124', len, dirtyComponents.length) : void 0;
// Since reconciling a component higher in the owner hierarchy usually (not
// always -- see shouldComponentUpdate()) will reconcile children, reconcile
// them before their children by sorting the array.
dirtyComponents.sort(mountOrderComparator);
// Any updates enqueued while reconciling must be performed after this entire
// batch. Otherwise, if dirtyComponents is [A, B] where A has children B and
// C, B could update twice in a single batch if C's render enqueues an update
// to B (since B would have already updated, we should skip it, and the only
// way we can know to do so is by checking the batch counter).
updateBatchNumber++;
for (var i = 0; i < len; i++) {
// If a component is unmounted before pending changes apply, it will still
// be here, but we assume that it has cleared its _pendingCallbacks and
// that performUpdateIfNecessary is a noop.
var component = dirtyComponents[i];
// If performUpdateIfNecessary happens to enqueue any new updates, we
// shouldn't execute the callbacks until the next render happens, so
// stash the callbacks first
var callbacks = component._pendingCallbacks;
component._pendingCallbacks = null;
var markerName;
if (ReactFeatureFlags.logTopLevelRenders) {
var namedComponent = component;
// Duck type TopLevelWrapper. This is probably always true.
if (component._currentElement.type.isReactTopLevelWrapper) {
namedComponent = component._renderedComponent;
}
markerName = 'React update: ' + namedComponent.getName();
console.time(markerName);
}
ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction, updateBatchNumber);
if (markerName) {
console.timeEnd(markerName);
}
if (callbacks) {
for (var j = 0; j < callbacks.length; j++) {
transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance());
}
}
}
} | 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 calls.
while (dirtyComponents.length || asapEnqueued) {
if (dirtyComponents.length) {
var transaction = ReactUpdatesFlushTransaction.getPooled();
transaction.perform(runBatchedUpdates, null, transaction);
ReactUpdatesFlushTransaction.release(transaction);
}
if (asapEnqueued) {
asapEnqueued = false;
var queue = asapCallbackQueue;
asapCallbackQueue = CallbackQueue.getPooled();
queue.notifyAll();
CallbackQueue.release(queue);
}
}
} | Mark a component as needing a rerender, adding an optional callback to a
list of functions which will be executed once the rerender occurs. | 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, etc.; creation and
// destruction of top-level components is guarded in ReactMount.)
if (!batchingStrategy.isBatchingUpdates) {
batchingStrategy.batchedUpdates(enqueueUpdate, component);
return;
}
dirtyComponents.push(component);
if (component._updateBatchNumber == null) {
component._updateBatchNumber = updateBatchNumber + 1;
}
} | Enqueue a callback to be run at the end of the current batching cycle. Throws
if no updates are currently being performed. | 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);
asapEnqueued = true;
} | 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;
} | Invokes all enqueued callbacks and clears the queue. This is invoked after
the DOM representation of a component has been created or updated.
@internal | 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);
} | Initializes the component, renders markup, and registers event listeners.
@param {ReactComponent} internalInstance
@param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
@param {?object} the containing host component instance
@param {?object} info about the host container
@return {?string} Rendered markup to be inserted into the DOM.
@final
@internal | 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');
} | ReactOwners are capable of storing references to owned components.
All components are capable of //being// referenced by owner components, but
only ReactOwner components are capable of //referencing// owned components.
The named reference is known as a "ref".
Refs are available when mounted and updated during reconciliation.
var MyComponent = React.createClass({
render: function() {
return (
<div onClick={this.handleClick}>
<CustomComponent ref="custom" />
</div>
);
},
handleClick: function() {
this.refs.custom.handleClick();
},
componentDidMount: function() {
this.refs.custom.initialize();
}
});
Refs should rarely be used. When refs are used, they should only be done to
control data that is not handled by React's data flow.
@class ReactOwner | isValidOwner | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isEventSupported(eventNameSuffix, capture) {
if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) {
return false;
}
var eventName = 'on' + eventNameSuffix;
var isSupported = eventName in document;
if (!isSupported) {
var element = document.createElement('div');
element.setAttribute(eventName, 'return;');
isSupported = typeof element[eventName] === 'function';
}
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
// This is the only way to test support for the `wheel` event in IE9+.
isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
}
return isSupported;
} | @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary | isEventSupported | 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;
} | Module that is injectable into `EventPluginHub`, that specifies a
deterministic ordering of `EventPlugin`s. A convenient way to reason about
plugins, without having to package every one of them. This is better than
having plugins be ordered in the same order that they are injected because
that ordering would be influenced by the packaging order.
`ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
preventing default on events is convenient in `SimpleEventPlugin` handlers. | 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);
} | @interface UIEvent
@see http://www.w3.org/TR/DOM-Level-3-Events/ | SyntheticMouseEvent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getNodeAfter(parentNode, node) {
// Special case for text components, which return [open, close] comments
// from getHostNode.
if (Array.isArray(node)) {
node = node[1];
}
return node ? node.nextSibling : parentNode.firstChild;
} | 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 | getNodeAfter | 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 one if stringText isn't empty.
if (stringText) {
insertChildAt(parentNode, document.createTextNode(stringText), nodeAfterComment);
}
} else {
if (stringText) {
// Set the text content of the first node after the opening comment, and
// remove all following nodes up until the closing comment.
setTextContent(nodeAfterComment, stringText);
removeDelimitedText(parentNode, nodeAfterComment, closingComment);
} else {
removeDelimitedText(parentNode, openingComment, closingComment);
}
}
if (process.env.NODE_ENV !== 'production') {
ReactInstrumentation.debugTool.onHostOperation({
instanceID: ReactDOMComponentTree.getInstanceFromNode(openingComment)._debugID,
type: 'replace text',
payload: stringText
});
}
} | 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(node, tree.html);
} else if (tree.text != null) {
setTextContent(node, tree.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 order
(in Firefox, twice as slow) so we only do this inversion in IE.
See https://github.com/spicyj/innerhtml-vs-createelement-vs-clonenode. | insertTreeChildren | 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)) {
case 34:
// "
escape = '"';
break;
case 38:
// &
escape = '&';
break;
case 39:
// '
escape = '''; // modified from escape-html; used to be '''
break;
case 60:
// <
escape = '<';
break;
case 62:
// >
escape = '>';
break;
default:
continue;
}
if (lastIndex !== index) {
html += str.substring(lastIndex, index);
}
lastIndex = index + 1;
html += escape;
}
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
} | Escapes text to prevent scripting attacks.
@param {*} text Text value to escape.
@return {string} An escaped string. | escapeHtml | 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();
} | 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 string of valid HTML markup.
@param {?function} handleScript Invoked once for each rendered <script>.
@return {array<DOMElement|DOMTextNode>} An array of rendered nodes. | getNodeName | 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: Array-like object expected') : invariant(false) : void 0;
!(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0;
!(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0;
!(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0;
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
// without method will throw during the slice call and skip straight to the
// fallback.
if (obj.hasOwnProperty) {
try {
return Array.prototype.slice.call(obj);
} catch (e) {
// IE < 9 does not support Array#slice on collections objects
}
}
// Fall back to copying key by key. This assumes all keys have a value,
// so will not preserve sparsely populated inputs.
var ret = Array(length);
for (var ii = 0; ii < length; ii++) {
ret[ii] = obj[ii];
}
return ret;
} | 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 DOM node should be considered an array-like
// a 'select' element has 'length' and 'item' properties on IE8
typeof obj.nodeType != 'number' && (
// a real array
Array.isArray(obj) ||
// arguments
'callee' in obj ||
// HTMLCollection/NodeList
'item' in 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);
...
}
This allows you to treat `things' as an array, but accept scalars in the API.
If you need to convert an array-like object, like `arguments`, into an array
use toArray instead.
@param {*} obj
@return {array} | 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);
}
} | Dummy container used to detect which wraps are necessary. | createArrayFromMixed | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function checkAndWarnForMutatedStyle(style1, style2, component) {
if (style1 == null || style2 == null) {
return;
}
if (shallowEqual(style1, style2)) {
return;
}
var componentName = component._tag;
var owner = component._currentElement._owner;
var ownerName;
if (owner) {
ownerName = owner.getName();
}
var hash = ownerName + '|' + componentName;
if (styleMutationWarning.hasOwnProperty(hash)) {
return;
}
styleMutationWarning[hash] = true;
process.env.NODE_ENV !== 'production' ? warning(false, '`%s` was passed a style object that has previously been mutated. ' + 'Mutating `style` is deprecated. Consider cloning it beforehand. Check ' + 'the `render` %s. Previous style: %s. Mutated style: %s.', componentName, owner ? 'of `' + ownerName + '`' : 'using <' + componentName + '>', friendlyStringify(style1), friendlyStringify(style2)) : void 0;
} | @param {object} component
@param {?object} props | checkAndWarnForMutatedStyle | 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 is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : _prodInvariant('137', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : void 0;
}
if (props.dangerouslySetInnerHTML != null) {
!(props.children == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : _prodInvariant('60') : void 0;
!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.') : _prodInvariant('61') : void 0;
}
if (process.env.NODE_ENV !== 'production') {
process.env.NODE_ENV !== 'production' ? warning(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.') : void 0;
process.env.NODE_ENV !== 'production' ? warning(props.suppressContentEditableWarning || !props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : void 0;
process.env.NODE_ENV !== 'production' ? warning(props.onFocusIn == null && props.onFocusOut == null, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.') : void 0;
}
!(props.style == null || typeof props.style === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s', getDeclarationErrorAddendum(component)) : _prodInvariant('62', getDeclarationErrorAddendum(component)) : void 0;
} | @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.NODE_ENV !== 'production' ? warning(registrationName !== 'onScroll' || isEventSupported('scroll', true), 'This browser doesn\'t support the `onScroll` event') : void 0;
}
var containerInfo = inst._hostContainerInfo;
var isDocumentFragment = containerInfo._node && containerInfo._node.nodeType === DOC_FRAGMENT_TYPE;
var doc = isDocumentFragment ? containerInfo._node : containerInfo._ownerDocument;
listenTo(registrationName, doc);
transaction.getReactMountReady().enqueue(putListener, {
inst: inst,
registrationName: registrationName,
listener: listener
});
} | @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') : _prodInvariant('63') : void 0;
var node = getNode(inst);
!node ? process.env.NODE_ENV !== 'production' ? invariant(false, 'trapBubbledEvent(...): Requires node to be rendered.') : _prodInvariant('64') : void 0;
switch (inst._tag) {
case 'iframe':
case 'object':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topLoad', 'load', node)];
break;
case 'video':
case 'audio':
inst._wrapperState.listeners = [];
// Create listener for each media event
for (var event in mediaEvents) {
if (mediaEvents.hasOwnProperty(event)) {
inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(event, mediaEvents[event], node));
}
}
break;
case 'source':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topError', 'error', node)];
break;
case 'img':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topError', 'error', node), ReactBrowserEventEmitter.trapBubbledEvent('topLoad', 'load', node)];
break;
case 'form':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topReset', 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent('topSubmit', 'submit', node)];
break;
case 'input':
case 'select':
case 'textarea':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topInvalid', 'invalid', node)];
break;
}
} | @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;
}
} | 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 functions differently from the DOM API. It accepts an
object mapping of style properties to values.
@constructor ReactDOMComponent
@extends ReactMultiChild | 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;
} | 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 functions differently from the DOM API. It accepts an
object mapping of style properties to values.
@constructor ReactDOMComponent
@extends ReactMultiChild | 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;
this._hostParent = null;
this._rootNodeID = 0;
this._domID = 0;
this._hostContainerInfo = null;
this._wrapperState = null;
this._topLevelWrapper = null;
this._flags = 0;
if (process.env.NODE_ENV !== 'production') {
this._ancestorInfo = null;
setAndValidateContentChildDev.call(this, null);
}
} | Generates root tag markup then recurses. This method has side effects and
is not idempotent.
@internal
@param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
@param {?ReactDOMComponent} the parent component instance
@param {?object} info about the host container
@param {object} context
@return {string} The computed markup. | ReactDOMComponent | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
warnStyleValueWithSemicolon = function (name, value, owner) {
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
return;
}
warnedStyleValues[value] = true;
process.env.NODE_ENV !== 'production' ? warning(false, 'Style property values shouldn\'t contain a semicolon.%s ' + 'Try "%s: %s" instead.', checkRenderMessage(owner), name, value.replace(badStyleValueWithSemicolonPattern, '')) : void 0;
} | @param {string} name
@param {*} value
@param {ReactDOMComponent} component | warnStyleValueWithSemicolon | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
warnStyleValueIsNaN = function (name, value, owner) {
if (warnedForNaNValue) {
return;
}
warnedForNaNValue = true;
process.env.NODE_ENV !== 'production' ? warning(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)) : void 0;
} | @param {string} name
@param {*} value
@param {ReactDOMComponent} component | warnStyleValueIsNaN | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
checkRenderMessage = function (owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
} | Operations for dealing with CSS properties. | checkRenderMessage | 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(name, owner);
} else if (badStyleValueWithSemicolonPattern.test(value)) {
warnStyleValueWithSemicolon(name, value, owner);
}
if (typeof value === 'number' && isNaN(value)) {
warnStyleValueIsNaN(name, value, owner);
}
} | Serializes a mapping of style properties for use as inline styles:
> createMarkupForStyles({width: '200px', height: 0})
"width:200px;height:0;"
Undefined values are ignored so that declarative programming is easier.
The result should be HTML-escaped before insertion into the DOM.
@param {object} styles
@param {ReactDOMComponent} component
@return {?string} | 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);
} | Most style properties can be unset by doing .style[prop] = '' but IE8
doesn't like doing that with shorthand properties so for the properties that
IE8 breaks on, which are listed here, we instead unset each of the
individual properties. See http://bugs.jquery.com/ticket/12385.
The 4-value 'clock' properties like margin, padding, border-width seem to
behave without any problems. Curiously, list-style works too without any
special prodding. | 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();
});
} | 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} Normalized style value with dimensions applied. | 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 couldn't repro this):
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
// This is not an XSS hole but instead a potential CSS injection issue
// which has lead to a greater discussion about how we're going to
// trust URLs moving forward. See #2115901
var isEmpty = value == null || typeof value === 'boolean' || value === '';
if (isEmpty) {
return '';
}
var isNonNumeric = isNaN(value);
if (isNonNumeric || value === 0 || isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
return '' + value; // cast to string
}
if (typeof value === 'string') {
if (process.env.NODE_ENV !== 'production') {
// Allow '0' to pass through without warning. 0 is already special and
// doesn't require units, so we don't need to warn about it.
if (component && value !== '0') {
var owner = component._currentElement._owner;
var ownerName = owner ? owner.getName() : null;
if (ownerName && !styleWarnings[ownerName]) {
styleWarnings[ownerName] = {};
}
var warned = false;
if (ownerName) {
var warnings = styleWarnings[ownerName];
warned = warnings[name];
if (!warned) {
warnings[name] = true;
}
}
if (!warned) {
process.env.NODE_ENV !== 'production' ? warning(false, 'a `%s` tag (owner: `%s`) was passed a numeric string value ' + 'for CSS property `%s` (value: `%s`) which will be treated ' + 'as a unitless number in a future version of React.', component._currentElement.type, ownerName || 'unknown', name, value) : void 0;
}
}
}
value = value.trim();
}
return value + 'px';
} | 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} Normalized style value with dimensions applied. | dangerousStyleValue | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isAttributeNameSafe(attributeName) {
if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
return true;
}
if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
return false;
}
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
validatedAttributeNameCache[attributeName] = true;
return true;
}
illegalAttributeNameCache[attributeName] = true;
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : void 0;
return false;
} | Creates markup for the ID property.
@param {string} id Unescaped ID.
@return {string} Markup string. | isAttributeNameSafe | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function shouldIgnoreValue(propertyInfo, value) {
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
} | Creates markup for a property.
@param {string} name
@param {*} value
@return {?string} Markup string, or null if the property was invalid. | shouldIgnoreValue | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function runEventQueueInBatch(events) {
EventPluginHub.enqueueEvents(events);
EventPluginHub.processEventQueue(false);
} | Generate a mapping of standard vendor prefixes using the defined style property and event name.
@param {string} styleProp
@param {string} eventName
@returns {object} | runEventQueueInBatch | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function forceUpdateIfMounted() {
if (this._rootNodeID) {
// DOM component is still mounted; update
ReactDOMInput.updateWrapper(this);
}
} | 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 null/undefined), the rendered element will not
trigger updates to the element. Instead, the props must change in order for
the rendered element to be updated.
The rendered element will be initialized as unchecked (or `defaultChecked`)
with an empty value (or `defaultValue`).
@see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html | forceUpdateIfMounted | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function isControlled(props) {
var usesChecked = props.type === 'checkbox' || props.type === 'radio';
return usesChecked ? props.checked != null : props.value != null;
} | 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 null/undefined), the rendered element will not
trigger updates to the element. Instead, the props must change in order for
the rendered element to be updated.
The rendered element will be initialized as unchecked (or `defaultChecked`)
with an empty value (or `defaultValue`).
@see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html | isControlled | 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/react/issues/1698
ReactUpdates.asap(forceUpdateIfMounted, this);
var name = props.name;
if (props.type === 'radio' && name != null) {
var rootNode = ReactDOMComponentTree.getNodeFromInstance(this);
var queryRoot = rootNode;
while (queryRoot.parentNode) {
queryRoot = queryRoot.parentNode;
}
// If `rootNode.form` was non-null, then we could try `form.elements`,
// but that sometimes behaves strangely in IE8. We could also try using
// `form.getElementsByName`, but that will only return direct children
// and won't include inputs that use the HTML5 `form=` attribute. Since
// the input might not even be in a form, let's just use the global
// `querySelectorAll` to ensure we don't miss anything.
var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
for (var i = 0; i < group.length; i++) {
var otherNode = group[i];
if (otherNode === rootNode || otherNode.form !== rootNode.form) {
continue;
}
// This will throw if radio buttons rendered by different copies of React
// and the same name are rendered into the same form (same as #1939).
// That's probably okay; we don't support it just as we don't support
// mixing React radio buttons with non-React ones.
var otherInstance = ReactDOMComponentTree.getInstanceFromNode(otherNode);
!otherInstance ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.') : _prodInvariant('90') : void 0;
// If this is a controlled radio button group, forcing the input that
// was previously checked to update will cause it to be come re-checked
// as appropriate.
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
}
}
return returnValue;
} | 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 null/undefined), the rendered element will not
trigger updates to the element. Instead, the props must change in order for
the rendered element to be updated.
The rendered element will be initialized as unchecked (or `defaultChecked`)
with an empty value (or `defaultValue`).
@see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html | _handleChange | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getDeclarationErrorAddendum(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
} | @param {object} inputProps Props for form component
@return {*} current value of the input either from value prop or link. | getDeclarationErrorAddendum | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function flattenChildren(children) {
var content = '';
// Flatten children and warn if they aren't strings or numbers;
// invalid types are ignored.
React.Children.forEach(children, function (child) {
if (child == null) {
return;
}
if (typeof child === 'string' || typeof child === 'number') {
content += child;
} else if (!didWarnInvalidOptionChildren) {
didWarnInvalidOptionChildren = true;
process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : void 0;
}
});
return content;
} | Implements an <option> host component that warns when `selected` is set. | flattenChildren | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function updateOptionsIfPendingUpdateAndMounted() {
if (this._rootNodeID && this._wrapperState.pendingUpdate) {
this._wrapperState.pendingUpdate = false;
var props = this._currentElement.props;
var value = LinkedValueUtils.getValue(props);
if (value != null) {
updateOptions(this, Boolean(props.multiple), value);
}
}
} | Validation function for `value` and `defaultValue`.
@private | updateOptionsIfPendingUpdateAndMounted | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getDeclarationErrorAddendum(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
} | Validation function for `value` and `defaultValue`.
@private | getDeclarationErrorAddendum | 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 `value` and `onChange` instead.') : void 0;
didWarnValueLink = true;
}
for (var i = 0; i < valuePropNames.length; i++) {
var propName = valuePropNames[i];
if (props[propName] == null) {
continue;
}
var isArray = Array.isArray(props[propName]);
if (props.multiple && !isArray) {
process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
} else if (!props.multiple && isArray) {
process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
}
}
} | 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 < options.length; i++) {
var selected = selectedValue.hasOwnProperty(options[i].value);
if (options[i].selected !== selected) {
options[i].selected = selected;
}
}
} else {
// Do not set `select.value` as exact behavior isn't consistent across all
// browsers for all cases.
selectedValue = '' + propValue;
for (i = 0; i < options.length; i++) {
if (options[i].value === selectedValue) {
options[i].selected = true;
return;
}
}
if (options.length) {
options[0].selected = true;
}
}
} | @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 forceUpdateIfMounted() {
if (this._rootNodeID) {
// DOM component is still mounted; update
ReactDOMTextarea.updateWrapper(this);
}
} | 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 supplied (and not null/undefined), the rendered element will
not trigger updates to the element. Instead, the `value` prop must change in
order for the rendered element to be updated.
The rendered element will be initialized with an empty value, the prop
`defaultValue` if specified, or the children content (deprecated). | forceUpdateIfMounted | 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 removing an element at an index.
@param {number} fromIndex Index of the element to remove.
@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 setting the text content.
@param {string} textContent Text content to set.
@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
};
} | Push an update, if any, onto the queue. Creates a new queue if none is
passed and always returns the queue. Mutative. | makeRemove | 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;
} | ReactMultiChild are capable of reconciling multiple children.
@class ReactMultiChild
@internal | enqueue | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function processQueue(inst, updateQueue) {
ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);
} | ReactMultiChild are capable of reconciling multiple children.
@class ReactMultiChild
@internal | processQueue | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
getDebugID = function (inst) {
if (!inst._debugID) {
// Check for ART-like instances. TODO: This is silly/gross.
var internal;
if (internal = ReactInstanceMap.get(inst)) {
inst = internal;
}
}
return inst._debugID;
} | Provides common functionality for components that must reconcile multiple
children. This is used by `ReactDOMComponent` to mount, update, and
unmount child components.
@lends {ReactMultiChild.prototype} | getDebugID | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function instantiateChild(childInstances, child, name, selfDebugID) {
// We found a component instance.
var keyUnique = childInstances[name] === undefined;
if (process.env.NODE_ENV !== 'production') {
if (!ReactComponentTreeHook) {
ReactComponentTreeHook = __webpack_require__(28);
}
if (!keyUnique) {
process.env.NODE_ENV !== 'production' ? warning(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeHook.getStackAddendumByID(selfDebugID)) : void 0;
}
}
if (child != null && keyUnique) {
childInstances[name] = instantiateReactComponent(child, true);
}
} | ReactChildReconciler provides helpers for initializing or updating a set of
children. Its output is suitable for passing it onto ReactMultiChild which
does diffed reordering and insertion. | instantiateChild | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getDeclarationErrorAddendum(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
} | 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 | getDeclarationErrorAddendum | 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';
} | 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 | 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 !== 'function' && typeof type !== 'string') {
var info = '';
if (process.env.NODE_ENV !== 'production') {
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.';
}
}
info += getDeclarationErrorAddendum(element._owner);
true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info) : _prodInvariant('130', type == null ? type : typeof type, info) : void 0;
}
// Special case string values
if (typeof element.type === 'string') {
instance = ReactHostComponent.createInternalComponent(element);
} else if (isInternalComponentType(element.type)) {
// This is temporarily available for custom components that are not string
// representations. I.e. ART. Once those are updated to use the string
// representation, we can drop this code path.
instance = new element.type(element);
// We renamed this. Allow the old name for compat. :(
if (!instance.getHostNode) {
instance.getHostNode = instance.getNativeNode;
}
} else {
instance = new ReactCompositeComponentWrapper(element);
}
} else if (typeof node === 'string' || typeof node === 'number') {
instance = ReactHostComponent.createInstanceForText(node);
} else {
true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : _prodInvariant('131', typeof node) : void 0;
}
if (process.env.NODE_ENV !== 'production') {
process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getHostNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
}
// These two fields are used by the DOM and ART diffing algorithms
// respectively. Instead of using expandos on components, we should be
// storing the state needed by the diffing algorithms elsewhere.
instance._mountIndex = 0;
instance._mountImage = null;
if (process.env.NODE_ENV !== 'production') {
instance._debugID = shouldHaveDebugID ? getNextDebugID() : 0;
}
// Internal instances should fully constructed at this point, so they should
// not get any new fields added to them at this point.
if (process.env.NODE_ENV !== 'production') {
if (Object.preventExtensions) {
Object.preventExtensions(instance);
}
}
return instance;
} | 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 didn't fail before. So we log it.
// After these have been cleaned up, we'll let them throw.
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
!(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
} catch (ex) {
error = ex;
}
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName, typeof error) : void 0;
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
// same error.
loggedTypeFailures[error.message] = true;
var componentStackInfo = '';
if (process.env.NODE_ENV !== 'production') {
if (!ReactComponentTreeHook) {
ReactComponentTreeHook = __webpack_require__(28);
}
if (debugID !== null) {
componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
} else if (element !== null) {
componentStackInfo = ReactComponentTreeHook.getCurrentStackAddendum(element);
}
}
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, componentStackInfo) : void 0;
}
}
}
} | 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} componentName Name of the component for error messages.
@param {?object} element The React element that is being type-checked
@param {?number} debugID The React component instance that is being type-checked
@private | checkReactTypeSpec | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function getNextDebugID() {
return nextDebugID++;
} | Unescape and unwrap key for human-readable display
@param {string} key to unescape.
@return {string} the unescaped key. | getNextDebugID | 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.key);
}
// Implicit key determined by the index in the set
return index.toString(36);
} | @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. | 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' ||
// The following is inlined from ReactElement. This means we can optimize
// some checks. React Fiber also inlines this logic for similar purposes.
type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) {
callback(traverseContext, children,
// If it's the only child, treat the name as if it was wrapped in an array
// so that it's consistent if the number of children grows.
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
return 1;
}
var child;
var nextName;
var subtreeCount = 0; // Count of children found in the current subtree.
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
if (Array.isArray(children)) {
for (var i = 0; i < children.length; i++) {
child = children[i];
nextName = nextNamePrefix + getComponentKey(child, i);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
} else {
var iteratorFn = getIteratorFn(children);
if (iteratorFn) {
var iterator = iteratorFn.call(children);
var step;
if (iteratorFn !== children.entries) {
var ii = 0;
while (!(step = iterator.next()).done) {
child = step.value;
nextName = nextNamePrefix + getComponentKey(child, ii++);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
} else {
if (process.env.NODE_ENV !== 'production') {
var mapsAsChildrenAddendum = '';
if (ReactCurrentOwner.current) {
var mapsAsChildrenOwnerName = ReactCurrentOwner.current.getName();
if (mapsAsChildrenOwnerName) {
mapsAsChildrenAddendum = ' Check the render method of `' + mapsAsChildrenOwnerName + '`.';
}
}
process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.%s', mapsAsChildrenAddendum) : void 0;
didWarnAboutMaps = true;
}
// Iterator will provide entry [k,v] tuples rather than values.
while (!(step = iterator.next()).done) {
var entry = step.value;
if (entry) {
child = entry[1];
nextName = nextNamePrefix + KeyEscapeUtils.escape(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
}
}
} else if (type === 'object') {
var addendum = '';
if (process.env.NODE_ENV !== 'production') {
addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.';
if (children._isReactElement) {
addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.';
}
if (ReactCurrentOwner.current) {
var name = ReactCurrentOwner.current.getName();
if (name) {
addendum += ' Check the render method of `' + name + '`.';
}
}
}
var childrenString = String(children);
true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : _prodInvariant('31', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : void 0;
}
}
return subtreeCount;
} | @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 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') {
if (!ReactComponentTreeHook) {
ReactComponentTreeHook = __webpack_require__(28);
}
if (!keyUnique) {
process.env.NODE_ENV !== 'production' ? warning(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeHook.getStackAddendumByID(selfDebugID)) : void 0;
}
}
if (keyUnique && child != null) {
result[name] = child;
}
}
} | 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. | flattenSingleChildIntoContext | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function warnNoop(publicInstance, callerName) {
if (process.env.NODE_ENV !== 'production') {
var constructor = publicInstance.constructor;
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
}
} | Checks whether or not this composite component is mounted.
@param {ReactClass} publicInstance The instance we want to test.
@return {boolean} True if mounted, false otherwise.
@protected
@final | warnNoop | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
function ReactServerUpdateQueue(transaction) {
_classCallCheck(this, ReactServerUpdateQueue);
this.transaction = transaction;
} | Enqueue a callback that will be executed after all the pending updates
have processed.
@param {ReactClass} publicInstance The instance to use as `this` context.
@param {?function} callback Called after state is updated.
@internal | ReactServerUpdateQueue | javascript | stitchfix/pyxley | tests/app/static/bundle.js | https://github.com/stitchfix/pyxley/blob/master/tests/app/static/bundle.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.