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 typeName(value) {
{
// toStringTag is needed for namespaced types like Temporal.Instant
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
return type;
}
} // $FlowFixMe only called in DEV, so void return is not possible.
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
typeName
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function willCoercionThrow(value) {
{
try {
testStringCoercion(value);
return false;
} catch (e) {
return true;
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
willCoercionThrow
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function testStringCoercion(value) {
// If you ended up here by following an exception call stack, here's what's
// happened: you supplied an object or symbol value to React (as a prop, key,
// DOM attribute, CSS property, string ref, etc.) and when React tried to
// coerce it to a string using `'' + value`, an exception was thrown.
//
// The most common types that will cause this exception are `Symbol` instances
// and Temporal objects like `Temporal.Instant`. But any object that has a
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
// exception. (Library authors do this to prevent users from using built-in
// numeric operators like `+` or comparison operators like `>=` because custom
// methods are needed to perform accurate arithmetic or comparison.)
//
// To fix the problem, coerce this object or symbol value to a string before
// passing it to React. The most reliable way is usually `String(value)`.
//
// To find which value is throwing, check the browser or debugger console.
// Before this exception was thrown, there should be `console.error` output
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
// problem and how that type was used: key, atrribute, input value prop, etc.
// In most cases, this console output also shows the component and its
// ancestor components where the exception happened.
//
// eslint-disable-next-line react-internal/safe-string-coercion
return '' + value;
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
testStringCoercion
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkAttributeStringCoercion(value, attributeName) {
{
if (willCoercionThrow(value)) {
error('The provided `%s` attribute is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', attributeName, typeName(value));
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
checkAttributeStringCoercion
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkKeyStringCoercion(value) {
{
if (willCoercionThrow(value)) {
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
checkKeyStringCoercion
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkPropStringCoercion(value, propName) {
{
if (willCoercionThrow(value)) {
error('The provided `%s` prop is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', propName, typeName(value));
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
checkPropStringCoercion
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkCSSPropertyStringCoercion(value, propName) {
{
if (willCoercionThrow(value)) {
error('The provided `%s` CSS property is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', propName, typeName(value));
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
checkCSSPropertyStringCoercion
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkHtmlStringCoercion(value) {
{
if (willCoercionThrow(value)) {
error('The provided HTML markup uses a value of unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
checkHtmlStringCoercion
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkFormFieldValueStringCoercion(value) {
{
if (willCoercionThrow(value)) {
error('Form field values (value, checked, defaultValue, or defaultChecked props)' + ' must be strings, not %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
checkFormFieldValueStringCoercion
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function isAttributeNameSafe(attributeName) {
if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
return true;
}
if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
return false;
}
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
validatedAttributeNameCache[attributeName] = true;
return true;
}
illegalAttributeNameCache[attributeName] = true;
{
error('Invalid attribute name: `%s`', attributeName);
}
return false;
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
isAttributeNameSafe
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
if (propertyInfo !== null) {
return propertyInfo.type === RESERVED;
}
if (isCustomComponentTag) {
return false;
}
if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
return true;
}
return false;
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
shouldIgnoreAttribute
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
if (propertyInfo !== null && propertyInfo.type === RESERVED) {
return false;
}
switch (typeof value) {
case 'function': // $FlowIssue symbol is perfectly valid here
case 'symbol':
// eslint-disable-line
return true;
case 'boolean':
{
if (isCustomComponentTag) {
return false;
}
if (propertyInfo !== null) {
return !propertyInfo.acceptsBooleans;
} else {
var prefix = name.toLowerCase().slice(0, 5);
return prefix !== 'data-' && prefix !== 'aria-';
}
}
default:
return false;
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
shouldRemoveAttributeWithWarning
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
if (value === null || typeof value === 'undefined') {
return true;
}
if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
return true;
}
if (isCustomComponentTag) {
return false;
}
if (propertyInfo !== null) {
switch (propertyInfo.type) {
case BOOLEAN:
return !value;
case OVERLOADED_BOOLEAN:
return value === false;
case NUMERIC:
return isNaN(value);
case POSITIVE_NUMERIC:
return isNaN(value) || value < 1;
}
}
return false;
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
shouldRemoveAttribute
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getPropertyInfo(name) {
return properties.hasOwnProperty(name) ? properties[name] : null;
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
getPropertyInfo
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
this.attributeName = attributeName;
this.attributeNamespace = attributeNamespace;
this.mustUseProperty = mustUseProperty;
this.propertyName = name;
this.type = type;
this.sanitizeURL = sanitizeURL;
this.removeEmptyString = removeEmptyString;
} // When adding attributes to this list, be sure to also add them to
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
PropertyInfoRecord
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
capitalize = function (token) {
return token[1].toUpperCase();
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
capitalize
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function sanitizeURL(url) {
{
if (!didWarn && isJavaScriptProtocol.test(url)) {
didWarn = true;
error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url));
}
}
}
|
Mapping from lowercase registration names to the properly cased version,
used to warn in the case of missing event handlers. Available
only in true.
@type {Object}
|
sanitizeURL
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getValueForProperty(node, name, expected, propertyInfo) {
{
if (propertyInfo.mustUseProperty) {
var propertyName = propertyInfo.propertyName;
return node[propertyName];
} else {
// This check protects multiple uses of `expected`, which is why the
// react-internal/safe-string-coercion rule is disabled in several spots
// below.
{
checkAttributeStringCoercion(expected, name);
}
if ( propertyInfo.sanitizeURL) {
// If we haven't fully disabled javascript: URLs, and if
// the hydration is successful of a javascript: URL, we
// still want to warn on the client.
// eslint-disable-next-line react-internal/safe-string-coercion
sanitizeURL('' + expected);
}
var attributeName = propertyInfo.attributeName;
var stringValue = null;
if (propertyInfo.type === OVERLOADED_BOOLEAN) {
if (node.hasAttribute(attributeName)) {
var value = node.getAttribute(attributeName);
if (value === '') {
return true;
}
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
return value;
} // eslint-disable-next-line react-internal/safe-string-coercion
if (value === '' + expected) {
return expected;
}
return value;
}
} else if (node.hasAttribute(attributeName)) {
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
// We had an attribute but shouldn't have had one, so read it
// for the error message.
return node.getAttribute(attributeName);
}
if (propertyInfo.type === BOOLEAN) {
// If this was a boolean, it doesn't matter what the value is
// the fact that we have it is the same as the expected.
return expected;
} // Even if this property uses a namespace we use getAttribute
// because we assume its namespaced name is the same as our config.
// To use getAttributeNS we need the local name which we don't have
// in our config atm.
stringValue = node.getAttribute(attributeName);
}
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
return stringValue === null ? expected : stringValue; // eslint-disable-next-line react-internal/safe-string-coercion
} else if (stringValue === '' + expected) {
return expected;
} else {
return stringValue;
}
}
}
}
|
Get the value for a property on a node. Only used in DEV for SSR validation.
The "expected" argument is used as a hint of what the expected value is.
Some properties have multiple equivalent values.
|
getValueForProperty
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getValueForAttribute(node, name, expected, isCustomComponentTag) {
{
if (!isAttributeNameSafe(name)) {
return;
}
if (!node.hasAttribute(name)) {
return expected === undefined ? undefined : null;
}
var value = node.getAttribute(name);
{
checkAttributeStringCoercion(expected, name);
}
if (value === '' + expected) {
return expected;
}
return value;
}
}
|
Get the value for a attribute on a node. Only used in DEV for SSR validation.
The third argument is used as a hint of what the expected value is. Some
attributes have multiple equivalent values.
|
getValueForAttribute
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function setValueForProperty(node, name, value, isCustomComponentTag) {
var propertyInfo = getPropertyInfo(name);
if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
return;
}
if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
value = null;
}
if (isCustomComponentTag || propertyInfo === null) {
if (isAttributeNameSafe(name)) {
var _attributeName = name;
if (value === null) {
node.removeAttribute(_attributeName);
} else {
{
checkAttributeStringCoercion(value, name);
}
node.setAttribute(_attributeName, '' + value);
}
}
return;
}
var mustUseProperty = propertyInfo.mustUseProperty;
if (mustUseProperty) {
var propertyName = propertyInfo.propertyName;
if (value === null) {
var type = propertyInfo.type;
node[propertyName] = type === BOOLEAN ? false : '';
} else {
// Contrary to `setAttribute`, object properties are properly
// `toString`ed by IE8/9.
node[propertyName] = value;
}
return;
} // The rest are treated as attributes with special cases.
var attributeName = propertyInfo.attributeName,
attributeNamespace = propertyInfo.attributeNamespace;
if (value === null) {
node.removeAttribute(attributeName);
} else {
var _type = propertyInfo.type;
var attributeValue;
if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
// If attribute type is boolean, we know for sure it won't be an execution sink
// and we won't require Trusted Type here.
attributeValue = '';
} else {
// `setAttribute` with objects becomes only `[object]` in IE8/9,
// ('' + value) makes it output the correct toString()-value.
{
{
checkAttributeStringCoercion(value, attributeName);
}
attributeValue = '' + value;
}
if (propertyInfo.sanitizeURL) {
sanitizeURL(attributeValue.toString());
}
}
if (attributeNamespace) {
node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
} else {
node.setAttribute(attributeName, attributeValue);
}
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
setValueForProperty
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getIteratorFn(maybeIterable) {
if (maybeIterable === null || typeof maybeIterable !== 'object') {
return null;
}
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
if (typeof maybeIterator === 'function') {
return maybeIterator;
}
return null;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getIteratorFn
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function disableLogs() {
{
if (disabledDepth === 0) {
/* eslint-disable react-internal/no-production-logging */
prevLog = console.log;
prevInfo = console.info;
prevWarn = console.warn;
prevError = console.error;
prevGroup = console.group;
prevGroupCollapsed = console.groupCollapsed;
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
var props = {
configurable: true,
enumerable: true,
value: disabledLog,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
Object.defineProperties(console, {
info: props,
log: props,
warn: props,
error: props,
group: props,
groupCollapsed: props,
groupEnd: props
});
/* eslint-enable react-internal/no-production-logging */
}
disabledDepth++;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
disableLogs
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function reenableLogs() {
{
disabledDepth--;
if (disabledDepth === 0) {
/* eslint-disable react-internal/no-production-logging */
var props = {
configurable: true,
enumerable: true,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
Object.defineProperties(console, {
log: assign({}, props, {
value: prevLog
}),
info: assign({}, props, {
value: prevInfo
}),
warn: assign({}, props, {
value: prevWarn
}),
error: assign({}, props, {
value: prevError
}),
group: assign({}, props, {
value: prevGroup
}),
groupCollapsed: assign({}, props, {
value: prevGroupCollapsed
}),
groupEnd: assign({}, props, {
value: prevGroupEnd
})
});
/* eslint-enable react-internal/no-production-logging */
}
if (disabledDepth < 0) {
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
}
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
reenableLogs
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function describeBuiltInComponentFrame(name, source, ownerFn) {
{
if (prefix === undefined) {
// Extract the VM specific prefix used by each line.
try {
throw Error();
} catch (x) {
var match = x.stack.trim().match(/\n( *(at )?)/);
prefix = match && match[1] || '';
}
} // We use the prefix to ensure our stacks line up with native stack frames.
return '\n' + prefix + name;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
describeBuiltInComponentFrame
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function describeNativeComponentFrame(fn, construct) {
// If something asked for a stack inside a fake render, it should get ignored.
if ( !fn || reentry) {
return '';
}
{
var frame = componentFrameCache.get(fn);
if (frame !== undefined) {
return frame;
}
}
var control;
reentry = true;
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
Error.prepareStackTrace = undefined;
var previousDispatcher;
{
previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
// for warnings.
ReactCurrentDispatcher.current = null;
disableLogs();
}
try {
// This should throw.
if (construct) {
// Something should be setting the props in the constructor.
var Fake = function () {
throw Error();
}; // $FlowFixMe
Object.defineProperty(Fake.prototype, 'props', {
set: function () {
// We use a throwing setter instead of frozen or non-writable props
// because that won't throw in a non-strict mode function.
throw Error();
}
});
if (typeof Reflect === 'object' && Reflect.construct) {
// We construct a different control for this case to include any extra
// frames added by the construct call.
try {
Reflect.construct(Fake, []);
} catch (x) {
control = x;
}
Reflect.construct(fn, [], Fake);
} else {
try {
Fake.call();
} catch (x) {
control = x;
}
fn.call(Fake.prototype);
}
} else {
try {
throw Error();
} catch (x) {
control = x;
}
fn();
}
} catch (sample) {
// This is inlined manually because closure doesn't do it for us.
if (sample && control && typeof sample.stack === 'string') {
// This extracts the first frame from the sample that isn't also in the control.
// Skipping one frame that we assume is the frame that calls the two.
var sampleLines = sample.stack.split('\n');
var controlLines = control.stack.split('\n');
var s = sampleLines.length - 1;
var c = controlLines.length - 1;
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
// We expect at least one stack frame to be shared.
// Typically this will be the root most one. However, stack frames may be
// cut off due to maximum stack limits. In this case, one maybe cut off
// earlier than the other. We assume that the sample is longer or the same
// and there for cut off earlier. So we should find the root most frame in
// the sample somewhere in the control.
c--;
}
for (; s >= 1 && c >= 0; s--, c--) {
// Next we find the first one that isn't the same which should be the
// frame that called our sample function and the control.
if (sampleLines[s] !== controlLines[c]) {
// In V8, the first line is describing the message but other VMs don't.
// If we're about to return the first line, and the control is also on the same
// line, that's a pretty good indicator that our sample threw at same line as
// the control. I.e. before we entered the sample frame. So we ignore this result.
// This can happen if you passed a class to function component, or non-function.
if (s !== 1 || c !== 1) {
do {
s--;
c--; // We may still have similar intermediate frames from the construct call.
// The next one that isn't the same should be our match though.
if (c < 0 || sampleLines[s] !== controlLines[c]) {
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
// but we have a user-provided "displayName"
// splice it in to make the stack more readable.
if (fn.displayName && _frame.includes('<anonymous>')) {
_frame = _frame.replace('<anonymous>', fn.displayName);
}
{
if (typeof fn === 'function') {
componentFrameCache.set(fn, _frame);
}
} // Return the line we found.
return _frame;
}
} while (s >= 1 && c >= 0);
}
break;
}
}
}
} finally {
reentry = false;
{
ReactCurrentDispatcher.current = previousDispatcher;
reenableLogs();
}
Error.prepareStackTrace = previousPrepareStackTrace;
} // Fallback to just using the name if we couldn't make it throw.
var name = fn ? fn.displayName || fn.name : '';
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
{
if (typeof fn === 'function') {
componentFrameCache.set(fn, syntheticFrame);
}
}
return syntheticFrame;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
describeNativeComponentFrame
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
Fake = function () {
throw Error();
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
Fake
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function describeClassComponentFrame(ctor, source, ownerFn) {
{
return describeNativeComponentFrame(ctor, true);
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
describeClassComponentFrame
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function describeFunctionComponentFrame(fn, source, ownerFn) {
{
return describeNativeComponentFrame(fn, false);
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
describeFunctionComponentFrame
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function shouldConstruct(Component) {
var prototype = Component.prototype;
return !!(prototype && prototype.isReactComponent);
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
shouldConstruct
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
if (type == null) {
return '';
}
if (typeof type === 'function') {
{
return describeNativeComponentFrame(type, shouldConstruct(type));
}
}
if (typeof type === 'string') {
return describeBuiltInComponentFrame(type);
}
switch (type) {
case REACT_SUSPENSE_TYPE:
return describeBuiltInComponentFrame('Suspense');
case REACT_SUSPENSE_LIST_TYPE:
return describeBuiltInComponentFrame('SuspenseList');
}
if (typeof type === 'object') {
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
return describeFunctionComponentFrame(type.render);
case REACT_MEMO_TYPE:
// Memo may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
case REACT_LAZY_TYPE:
{
var lazyComponent = type;
var payload = lazyComponent._payload;
var init = lazyComponent._init;
try {
// Lazy may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
} catch (x) {}
}
}
}
return '';
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
describeUnknownElementTypeFrameInDEV
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function describeFiber(fiber) {
var owner = fiber._debugOwner ? fiber._debugOwner.type : null ;
var source = fiber._debugSource ;
switch (fiber.tag) {
case HostComponent:
return describeBuiltInComponentFrame(fiber.type);
case LazyComponent:
return describeBuiltInComponentFrame('Lazy');
case SuspenseComponent:
return describeBuiltInComponentFrame('Suspense');
case SuspenseListComponent:
return describeBuiltInComponentFrame('SuspenseList');
case FunctionComponent:
case IndeterminateComponent:
case SimpleMemoComponent:
return describeFunctionComponentFrame(fiber.type);
case ForwardRef:
return describeFunctionComponentFrame(fiber.type.render);
case ClassComponent:
return describeClassComponentFrame(fiber.type);
default:
return '';
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
describeFiber
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getStackByFiberInDevAndProd(workInProgress) {
try {
var info = '';
var node = workInProgress;
do {
info += describeFiber(node);
node = node.return;
} while (node);
return info;
} catch (x) {
return '\nError generating stack: ' + x.message + '\n' + x.stack;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getStackByFiberInDevAndProd
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getWrappedName(outerType, innerType, wrapperName) {
var displayName = outerType.displayName;
if (displayName) {
return displayName;
}
var functionName = innerType.displayName || innerType.name || '';
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
} // Keep in sync with react-reconciler/getComponentNameFromFiber
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getWrappedName
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getContextName(type) {
return type.displayName || 'Context';
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getContextName
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getComponentNameFromType(type) {
if (type == null) {
// Host root, text node or just invalid type.
return null;
}
{
if (typeof type.tag === 'number') {
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
}
}
if (typeof type === 'function') {
return type.displayName || type.name || null;
}
if (typeof type === 'string') {
return type;
}
switch (type) {
case REACT_FRAGMENT_TYPE:
return 'Fragment';
case REACT_PORTAL_TYPE:
return 'Portal';
case REACT_PROFILER_TYPE:
return 'Profiler';
case REACT_STRICT_MODE_TYPE:
return 'StrictMode';
case REACT_SUSPENSE_TYPE:
return 'Suspense';
case REACT_SUSPENSE_LIST_TYPE:
return 'SuspenseList';
}
if (typeof type === 'object') {
switch (type.$$typeof) {
case REACT_CONTEXT_TYPE:
var context = type;
return getContextName(context) + '.Consumer';
case REACT_PROVIDER_TYPE:
var provider = type;
return getContextName(provider._context) + '.Provider';
case REACT_FORWARD_REF_TYPE:
return getWrappedName(type, type.render, 'ForwardRef');
case REACT_MEMO_TYPE:
var outerName = type.displayName || null;
if (outerName !== null) {
return outerName;
}
return getComponentNameFromType(type.type) || 'Memo';
case REACT_LAZY_TYPE:
{
var lazyComponent = type;
var payload = lazyComponent._payload;
var init = lazyComponent._init;
try {
return getComponentNameFromType(init(payload));
} catch (x) {
return null;
}
}
// eslint-disable-next-line no-fallthrough
}
}
return null;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getComponentNameFromType
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getWrappedName$1(outerType, innerType, wrapperName) {
var functionName = innerType.displayName || innerType.name || '';
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
} // Keep in sync with shared/getComponentNameFromType
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getWrappedName$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getContextName$1(type) {
return type.displayName || 'Context';
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getContextName$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getComponentNameFromFiber(fiber) {
var tag = fiber.tag,
type = fiber.type;
switch (tag) {
case CacheComponent:
return 'Cache';
case ContextConsumer:
var context = type;
return getContextName$1(context) + '.Consumer';
case ContextProvider:
var provider = type;
return getContextName$1(provider._context) + '.Provider';
case DehydratedFragment:
return 'DehydratedFragment';
case ForwardRef:
return getWrappedName$1(type, type.render, 'ForwardRef');
case Fragment:
return 'Fragment';
case HostComponent:
// Host component type is the display name (e.g. "div", "View")
return type;
case HostPortal:
return 'Portal';
case HostRoot:
return 'Root';
case HostText:
return 'Text';
case LazyComponent:
// Name comes from the type in this case; we don't have a tag.
return getComponentNameFromType(type);
case Mode:
if (type === REACT_STRICT_MODE_TYPE) {
// Don't be less specific than shared/getComponentNameFromType
return 'StrictMode';
}
return 'Mode';
case OffscreenComponent:
return 'Offscreen';
case Profiler:
return 'Profiler';
case ScopeComponent:
return 'Scope';
case SuspenseComponent:
return 'Suspense';
case SuspenseListComponent:
return 'SuspenseList';
case TracingMarkerComponent:
return 'TracingMarker';
// The display name for this tags come from the user-provided type:
case ClassComponent:
case FunctionComponent:
case IncompleteClassComponent:
case IndeterminateComponent:
case MemoComponent:
case SimpleMemoComponent:
if (typeof type === 'function') {
return type.displayName || type.name || null;
}
if (typeof type === 'string') {
return type;
}
break;
}
return null;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getComponentNameFromFiber
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getCurrentFiberOwnerNameInDevOrNull() {
{
if (current === null) {
return null;
}
var owner = current._debugOwner;
if (owner !== null && typeof owner !== 'undefined') {
return getComponentNameFromFiber(owner);
}
}
return null;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getCurrentFiberOwnerNameInDevOrNull
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getCurrentFiberStackInDev() {
{
if (current === null) {
return '';
} // Safe because if current fiber exists, we are reconciling,
// and it is guaranteed to be the work-in-progress version.
return getStackByFiberInDevAndProd(current);
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getCurrentFiberStackInDev
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function resetCurrentFiber() {
{
ReactDebugCurrentFrame.getCurrentStack = null;
current = null;
isRendering = false;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
resetCurrentFiber
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function setCurrentFiber(fiber) {
{
ReactDebugCurrentFrame.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev;
current = fiber;
isRendering = false;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
setCurrentFiber
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getCurrentFiber() {
{
return current;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getCurrentFiber
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function setIsRendering(rendering) {
{
isRendering = rendering;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
setIsRendering
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function toString(value) {
// The coercion safety check is performed in getToStringValue().
// eslint-disable-next-line react-internal/safe-string-coercion
return '' + value;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
toString
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getToStringValue(value) {
switch (typeof value) {
case 'boolean':
case 'number':
case 'string':
case 'undefined':
return value;
case 'object':
{
checkFormFieldValueStringCoercion(value);
}
return value;
default:
// function, symbol are assigned as empty strings
return '';
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getToStringValue
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkControlledValueProps(tagName, props) {
{
if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) {
error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
}
if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) {
error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
}
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
checkControlledValueProps
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function isCheckable(elem) {
var type = elem.type;
var nodeName = elem.nodeName;
return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
isCheckable
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getTracker(node) {
return node._valueTracker;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getTracker
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function detachTracker(node) {
node._valueTracker = null;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
detachTracker
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getValueFromNode(node) {
var value = '';
if (!node) {
return value;
}
if (isCheckable(node)) {
value = node.checked ? 'true' : 'false';
} else {
value = node.value;
}
return value;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getValueFromNode
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function trackValueOnNode(node) {
var valueField = isCheckable(node) ? 'checked' : 'value';
var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
{
checkFormFieldValueStringCoercion(node[valueField]);
}
var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail
// and don't track value will cause over reporting of changes,
// but it's better then a hard failure
// (needed for certain tests that spyOn input values and Safari)
if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
return;
}
var get = descriptor.get,
set = descriptor.set;
Object.defineProperty(node, valueField, {
configurable: true,
get: function () {
return get.call(this);
},
set: function (value) {
{
checkFormFieldValueStringCoercion(value);
}
currentValue = '' + value;
set.call(this, value);
}
}); // We could've passed this the first time
// but it triggers a bug in IE11 and Edge 14/15.
// Calling defineProperty() again should be equivalent.
// https://github.com/facebook/react/issues/11768
Object.defineProperty(node, valueField, {
enumerable: descriptor.enumerable
});
var tracker = {
getValue: function () {
return currentValue;
},
setValue: function (value) {
{
checkFormFieldValueStringCoercion(value);
}
currentValue = '' + value;
},
stopTracking: function () {
detachTracker(node);
delete node[valueField];
}
};
return tracker;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
trackValueOnNode
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function track(node) {
if (getTracker(node)) {
return;
} // TODO: Once it's just Fiber we can move this to node._wrapperState
node._valueTracker = trackValueOnNode(node);
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
track
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function updateValueIfChanged(node) {
if (!node) {
return false;
}
var tracker = getTracker(node); // if there is no tracker at this point it's unlikely
// that trying again will succeed
if (!tracker) {
return true;
}
var lastValue = tracker.getValue();
var nextValue = getValueFromNode(node);
if (nextValue !== lastValue) {
tracker.setValue(nextValue);
return true;
}
return false;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
updateValueIfChanged
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getActiveElement(doc) {
doc = doc || (typeof document !== 'undefined' ? document : undefined);
if (typeof doc === 'undefined') {
return null;
}
try {
return doc.activeElement || doc.body;
} catch (e) {
return doc.body;
}
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
getActiveElement
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function isControlled(props) {
var usesChecked = props.type === 'checkbox' || props.type === 'radio';
return usesChecked ? props.checked != null : props.value != null;
}
|
Sets the value for a property on a node.
@param {DOMElement} node
@param {string} name
@param {*} value
|
isControlled
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getHostProps(element, props) {
var node = element;
var checked = props.checked;
var hostProps = assign({}, props, {
defaultChecked: undefined,
defaultValue: undefined,
value: undefined,
checked: checked != null ? checked : node._wrapperState.initialChecked
});
return hostProps;
}
|
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
|
getHostProps
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function initWrapperState(element, props) {
{
checkControlledValueProps('input', props);
if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
error('%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
didWarnCheckedDefaultChecked = true;
}
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
error('%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
didWarnValueDefaultValue = true;
}
}
var node = element;
var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
node._wrapperState = {
initialChecked: props.checked != null ? props.checked : props.defaultChecked,
initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
controlled: isControlled(props)
};
}
|
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
|
initWrapperState
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function updateChecked(element, props) {
var node = element;
var checked = props.checked;
if (checked != null) {
setValueForProperty(node, 'checked', checked, false);
}
}
|
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
|
updateChecked
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function updateWrapper(element, props) {
var node = element;
{
var controlled = isControlled(props);
if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
error('A component is changing an uncontrolled input to be controlled. ' + 'This is likely caused by the value changing from undefined to ' + 'a defined value, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components');
didWarnUncontrolledToControlled = true;
}
if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
error('A component is changing a controlled input to be uncontrolled. ' + 'This is likely caused by the value changing from a defined to ' + 'undefined, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components');
didWarnControlledToUncontrolled = true;
}
}
updateChecked(element, props);
var value = getToStringValue(props.value);
var type = props.type;
if (value != null) {
if (type === 'number') {
if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible.
// eslint-disable-next-line
node.value != value) {
node.value = toString(value);
}
} else if (node.value !== toString(value)) {
node.value = toString(value);
}
} else if (type === 'submit' || type === 'reset') {
// Submit/reset inputs need the attribute removed completely to avoid
// blank-text buttons.
node.removeAttribute('value');
return;
}
{
// When syncing the value attribute, the value comes from a cascade of
// properties:
// 1. The value React property
// 2. The defaultValue React property
// 3. Otherwise there should be no change
if (props.hasOwnProperty('value')) {
setDefaultValue(node, props.type, value);
} else if (props.hasOwnProperty('defaultValue')) {
setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
}
}
{
// When syncing the checked attribute, it only changes when it needs
// to be removed, such as transitioning from a checkbox into a text input
if (props.checked == null && props.defaultChecked != null) {
node.defaultChecked = !!props.defaultChecked;
}
}
}
|
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
|
updateWrapper
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function postMountWrapper(element, props, isHydrating) {
var node = element; // Do not assign value if it is already set. This prevents user text input
// from being lost during SSR hydration.
if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
var type = props.type;
var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the
// default value provided by the browser. See: #12872
if (isButton && (props.value === undefined || props.value === null)) {
return;
}
var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input
// from being lost during SSR hydration.
if (!isHydrating) {
{
// When syncing the value attribute, the value property should use
// the wrapperState._initialValue property. This uses:
//
// 1. The value React property when present
// 2. The defaultValue React property when present
// 3. An empty string
if (initialValue !== node.value) {
node.value = initialValue;
}
}
}
{
// Otherwise, the value attribute is synchronized to the property,
// so we assign defaultValue to the same thing as the value property
// assignment step above.
node.defaultValue = initialValue;
}
} // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
// this is needed to work around a chrome bug where setting defaultChecked
// will sometimes influence the value of checked (even after detachment).
// Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
// We need to temporarily unset name to avoid disrupting radio button groups.
var name = node.name;
if (name !== '') {
node.name = '';
}
{
// When syncing the checked attribute, both the checked property and
// attribute are assigned at the same time using defaultChecked. This uses:
//
// 1. The checked React property when present
// 2. The defaultChecked React property when present
// 3. Otherwise, false
node.defaultChecked = !node.defaultChecked;
node.defaultChecked = !!node._wrapperState.initialChecked;
}
if (name !== '') {
node.name = name;
}
}
|
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
|
postMountWrapper
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function restoreControlledState(element, props) {
var node = element;
updateWrapper(node, props);
updateNamedCousins(node, props);
}
|
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
|
restoreControlledState
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function updateNamedCousins(rootNode, props) {
var name = props.name;
if (props.type === 'radio' && name != null) {
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. It might not even be in the
// document. Let's just use the local `querySelectorAll` to ensure we don't
// miss anything.
{
checkAttributeStringCoercion(name, 'name');
}
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 otherProps = getFiberCurrentPropsFromNode(otherNode);
if (!otherProps) {
throw new Error('ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.');
} // We need update the tracked value on the named cousin since the value
// was changed but the input saw no event or value set
updateValueIfChanged(otherNode); // 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.
updateWrapper(otherNode, otherProps);
}
}
} // In Chrome, assigning defaultValue to certain input types triggers input validation.
|
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
|
updateNamedCousins
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function setDefaultValue(node, type, value) {
if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
type !== 'number' || getActiveElement(node.ownerDocument) !== node) {
if (value == null) {
node.defaultValue = toString(node._wrapperState.initialValue);
} else if (node.defaultValue !== toString(value)) {
node.defaultValue = toString(value);
}
}
}
|
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
|
setDefaultValue
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function validateProps(element, props) {
{
// If a value is not provided, then the children must be simple.
if (props.value == null) {
if (typeof props.children === 'object' && props.children !== null) {
React.Children.forEach(props.children, function (child) {
if (child == null) {
return;
}
if (typeof child === 'string' || typeof child === 'number') {
return;
}
if (!didWarnInvalidChild) {
didWarnInvalidChild = true;
error('Cannot infer the option value of complex children. ' + 'Pass a `value` prop or use a plain string as children to <option>.');
}
});
} else if (props.dangerouslySetInnerHTML != null) {
if (!didWarnInvalidInnerHTML) {
didWarnInvalidInnerHTML = true;
error('Pass a `value` prop if you set dangerouslyInnerHTML so React knows ' + 'which value should be selected.');
}
}
} // TODO: Remove support for `selected` in <option>.
if (props.selected != null && !didWarnSelectedSetOnOption) {
error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
didWarnSelectedSetOnOption = true;
}
}
}
|
Implements an <option> host component that warns when `selected` is set.
|
validateProps
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function postMountWrapper$1(element, props) {
// value="" should make a value attribute (#6219)
if (props.value != null) {
element.setAttribute('value', toString(getToStringValue(props.value)));
}
}
|
Implements an <option> host component that warns when `selected` is set.
|
postMountWrapper$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function isArray(a) {
return isArrayImpl(a);
}
|
Implements an <option> host component that warns when `selected` is set.
|
isArray
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getDeclarationErrorAddendum() {
var ownerName = getCurrentFiberOwnerNameInDevOrNull();
if (ownerName) {
return '\n\nCheck the render method of `' + ownerName + '`.';
}
return '';
}
|
Implements an <option> host component that warns when `selected` is set.
|
getDeclarationErrorAddendum
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function checkSelectPropTypes(props) {
{
checkControlledValueProps('select', props);
for (var i = 0; i < valuePropNames.length; i++) {
var propName = valuePropNames[i];
if (props[propName] == null) {
continue;
}
var propNameIsArray = isArray(props[propName]);
if (props.multiple && !propNameIsArray) {
error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
} else if (!props.multiple && propNameIsArray) {
error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
}
}
}
}
|
Validation function for `value` and `defaultValue`.
|
checkSelectPropTypes
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function updateOptions(node, multiple, propValue, setDefaultSelected) {
var options = node.options;
if (multiple) {
var selectedValues = propValue;
var selectedValue = {};
for (var i = 0; i < selectedValues.length; i++) {
// Prefix to avoid chaos with special keys.
selectedValue['$' + selectedValues[i]] = true;
}
for (var _i = 0; _i < options.length; _i++) {
var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
if (options[_i].selected !== selected) {
options[_i].selected = selected;
}
if (selected && setDefaultSelected) {
options[_i].defaultSelected = true;
}
}
} else {
// Do not set `select.value` as exact behavior isn't consistent across all
// browsers for all cases.
var _selectedValue = toString(getToStringValue(propValue));
var defaultSelected = null;
for (var _i2 = 0; _i2 < options.length; _i2++) {
if (options[_i2].value === _selectedValue) {
options[_i2].selected = true;
if (setDefaultSelected) {
options[_i2].defaultSelected = true;
}
return;
}
if (defaultSelected === null && !options[_i2].disabled) {
defaultSelected = options[_i2];
}
}
if (defaultSelected !== null) {
defaultSelected.selected = true;
}
}
}
|
Validation function for `value` and `defaultValue`.
|
updateOptions
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getHostProps$1(element, props) {
return assign({}, props, {
value: undefined
});
}
|
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 will trigger updates to the rendered options.
If it is supplied (and not null/undefined), the rendered options will not
update in response to user actions. Instead, the `value` prop must change in
order for the rendered options to update.
If `defaultValue` is provided, any options with the supplied values will be
selected.
|
getHostProps$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function initWrapperState$1(element, props) {
var node = element;
{
checkSelectPropTypes(props);
}
node._wrapperState = {
wasMultiple: !!props.multiple
};
{
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
error('Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components');
didWarnValueDefaultValue$1 = true;
}
}
}
|
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 will trigger updates to the rendered options.
If it is supplied (and not null/undefined), the rendered options will not
update in response to user actions. Instead, the `value` prop must change in
order for the rendered options to update.
If `defaultValue` is provided, any options with the supplied values will be
selected.
|
initWrapperState$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function postMountWrapper$2(element, props) {
var node = element;
node.multiple = !!props.multiple;
var value = props.value;
if (value != null) {
updateOptions(node, !!props.multiple, value, false);
} else if (props.defaultValue != null) {
updateOptions(node, !!props.multiple, props.defaultValue, true);
}
}
|
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 will trigger updates to the rendered options.
If it is supplied (and not null/undefined), the rendered options will not
update in response to user actions. Instead, the `value` prop must change in
order for the rendered options to update.
If `defaultValue` is provided, any options with the supplied values will be
selected.
|
postMountWrapper$2
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function postUpdateWrapper(element, props) {
var node = element;
var wasMultiple = node._wrapperState.wasMultiple;
node._wrapperState.wasMultiple = !!props.multiple;
var value = props.value;
if (value != null) {
updateOptions(node, !!props.multiple, value, false);
} else if (wasMultiple !== !!props.multiple) {
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
if (props.defaultValue != null) {
updateOptions(node, !!props.multiple, props.defaultValue, true);
} else {
// Revert the select back to its default unselected state.
updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
}
}
}
|
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 will trigger updates to the rendered options.
If it is supplied (and not null/undefined), the rendered options will not
update in response to user actions. Instead, the `value` prop must change in
order for the rendered options to update.
If `defaultValue` is provided, any options with the supplied values will be
selected.
|
postUpdateWrapper
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function restoreControlledState$1(element, props) {
var node = element;
var value = props.value;
if (value != null) {
updateOptions(node, !!props.multiple, value, false);
}
}
|
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 will trigger updates to the rendered options.
If it is supplied (and not null/undefined), the rendered options will not
update in response to user actions. Instead, the `value` prop must change in
order for the rendered options to update.
If `defaultValue` is provided, any options with the supplied values will be
selected.
|
restoreControlledState$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getHostProps$2(element, props) {
var node = element;
if (props.dangerouslySetInnerHTML != null) {
throw new Error('`dangerouslySetInnerHTML` does not make sense on <textarea>.');
} // Always set children to the same thing. In IE9, the selection range will
// get reset if `textContent` is mutated. We could add a check in setTextContent
// to only set the value if/when the value differs from the node value (which would
// completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
// solution. The value can be a boolean or object so that's why it's forced
// to be a string.
var hostProps = assign({}, props, {
value: undefined,
defaultValue: undefined,
children: toString(node._wrapperState.initialValue)
});
return hostProps;
}
|
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).
|
getHostProps$2
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function initWrapperState$2(element, props) {
var node = element;
{
checkControlledValueProps('textarea', props);
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
error('%s contains a textarea with both value and defaultValue props. ' + 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
didWarnValDefaultVal = true;
}
}
var initialValue = props.value; // Only bother fetching default value if we're going to use it
if (initialValue == null) {
var children = props.children,
defaultValue = props.defaultValue;
if (children != null) {
{
error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
}
{
if (defaultValue != null) {
throw new Error('If you supply `defaultValue` on a <textarea>, do not pass children.');
}
if (isArray(children)) {
if (children.length > 1) {
throw new Error('<textarea> can only have at most one child.');
}
children = children[0];
}
defaultValue = children;
}
}
if (defaultValue == null) {
defaultValue = '';
}
initialValue = defaultValue;
}
node._wrapperState = {
initialValue: getToStringValue(initialValue)
};
}
|
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).
|
initWrapperState$2
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function updateWrapper$1(element, props) {
var node = element;
var value = getToStringValue(props.value);
var defaultValue = getToStringValue(props.defaultValue);
if (value != null) {
// Cast `value` to a string to ensure the value is set correctly. While
// browsers typically do this as necessary, jsdom doesn't.
var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed
if (newValue !== node.value) {
node.value = newValue;
}
if (props.defaultValue == null && node.defaultValue !== newValue) {
node.defaultValue = newValue;
}
}
if (defaultValue != null) {
node.defaultValue = toString(defaultValue);
}
}
|
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).
|
updateWrapper$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function postMountWrapper$3(element, props) {
var node = element; // This is in postMount because we need access to the DOM node, which is not
// available until after the component has mounted.
var textContent = node.textContent; // Only set node.value if textContent is equal to the expected
// initial value. In IE10/IE11 there is a bug where the placeholder attribute
// will populate textContent as well.
// https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
if (textContent === node._wrapperState.initialValue) {
if (textContent !== '' && textContent !== null) {
node.value = textContent;
}
}
}
|
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).
|
postMountWrapper$3
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function restoreControlledState$2(element, props) {
// DOM component is still mounted; update
updateWrapper$1(element, props);
}
|
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).
|
restoreControlledState$2
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getIntrinsicNamespace(type) {
switch (type) {
case 'svg':
return SVG_NAMESPACE;
case 'math':
return MATH_NAMESPACE;
default:
return HTML_NAMESPACE;
}
}
|
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).
|
getIntrinsicNamespace
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function getChildNamespace(parentNamespace, type) {
if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
// No (or default) parent namespace: potential entry point.
return getIntrinsicNamespace(type);
}
if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
// We're leaving SVG.
return HTML_NAMESPACE;
} // By default, pass namespace below.
return parentNamespace;
}
|
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).
|
getChildNamespace
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.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
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
setTextContent = function (node, text) {
if (text) {
var firstChild = node.firstChild;
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
firstChild.nodeValue = text;
return;
}
}
node.textContent = text;
}
|
Set the textContent property of a node. For text updates, it's faster
to set the `nodeValue` of the Text node directly instead of using
`.textContent` which will remove the existing node and create a new one.
@param {DOMElement} node
@param {string} text
@internal
|
setTextContent
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.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
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function dangerousStyleValue(name, value, isCustomProperty) {
// 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 '';
}
if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
}
{
checkCSSPropertyStringCoercion(value, name);
}
return ('' + value).trim();
}
|
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`.
@return {string} Normalized style value with dimensions applied.
|
dangerousStyleValue
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function hyphenateStyleName(name) {
return name.replace(uppercasePattern, '-$1').toLowerCase().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
is converted to `-ms-`.
|
hyphenateStyleName
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
camelize = function (string) {
return string.replace(hyphenPattern, function (_, character) {
return character.toUpperCase();
});
}
|
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
is converted to `-ms-`.
|
camelize
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
warnHyphenatedStyleName = function (name) {
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
return;
}
warnedStyleNames[name] = true;
error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests
// (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
// is converted to lowercase `ms`.
camelize(name.replace(msPattern$1, '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
is converted to `-ms-`.
|
warnHyphenatedStyleName
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
warnBadVendoredStyleName = function (name) {
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
return;
}
warnedStyleNames[name] = true;
error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
}
|
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
is converted to `-ms-`.
|
warnBadVendoredStyleName
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
warnStyleValueWithSemicolon = function (name, value) {
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
return;
}
warnedStyleValues[value] = true;
error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
}
|
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
is converted to `-ms-`.
|
warnStyleValueWithSemicolon
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
warnStyleValueIsNaN = function (name, value) {
if (warnedForNaNValue) {
return;
}
warnedForNaNValue = true;
error('`NaN` is an invalid value for the `%s` css style property.', name);
}
|
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
is converted to `-ms-`.
|
warnStyleValueIsNaN
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
warnStyleValueIsInfinity = function (name, value) {
if (warnedForInfinityValue) {
return;
}
warnedForInfinityValue = true;
error('`Infinity` is an invalid value for the `%s` css style property.', name);
}
|
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
is converted to `-ms-`.
|
warnStyleValueIsInfinity
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function createDangerousStringForStyles(styles) {
{
var serialized = '';
var delimiter = '';
for (var styleName in styles) {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
var styleValue = styles[styleName];
if (styleValue != null) {
var isCustomProperty = styleName.indexOf('--') === 0;
serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':';
serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
delimiter = ';';
}
}
return serialized || null;
}
}
|
This creates a string that is expected to be equivalent to the style
attribute generated by server-side rendering. It by-passes warnings and
security checks so it's not safe to use this value for anything other than
comparison. It is only used in DEV for SSR validation.
|
createDangerousStringForStyles
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function setValueForStyles(node, styles) {
var style = node.style;
for (var styleName in styles) {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
var isCustomProperty = styleName.indexOf('--') === 0;
{
if (!isCustomProperty) {
warnValidStyle$1(styleName, styles[styleName]);
}
}
var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
if (styleName === 'float') {
styleName = 'cssFloat';
}
if (isCustomProperty) {
style.setProperty(styleName, styleValue);
} else {
style[styleName] = styleValue;
}
}
}
|
Sets the value for multiple styles on a node. If a value is specified as
'' (empty string), the corresponding style property will be unset.
@param {DOMElement} node
@param {object} styles
|
setValueForStyles
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function isValueEmpty(value) {
return value == null || typeof value === 'boolean' || value === '';
}
|
Sets the value for multiple styles on a node. If a value is specified as
'' (empty string), the corresponding style property will be unset.
@param {DOMElement} node
@param {object} styles
|
isValueEmpty
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function expandShorthandMap(styles) {
var expanded = {};
for (var key in styles) {
var longhands = shorthandToLonghand[key] || [key];
for (var i = 0; i < longhands.length; i++) {
expanded[longhands[i]] = key;
}
}
return expanded;
}
|
Given {color: 'red', overflow: 'hidden'} returns {
color: 'color',
overflowX: 'overflow',
overflowY: 'overflow',
}. This can be read as "the overflowY property was set by the overflow
shorthand". That is, the values are the property that each was derived from.
|
expandShorthandMap
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
{
if (!nextStyles) {
return;
}
var expandedUpdates = expandShorthandMap(styleUpdates);
var expandedStyles = expandShorthandMap(nextStyles);
var warnedAbout = {};
for (var key in expandedUpdates) {
var originalKey = expandedUpdates[key];
var correctOriginalKey = expandedStyles[key];
if (correctOriginalKey && originalKey !== correctOriginalKey) {
var warningKey = originalKey + ',' + correctOriginalKey;
if (warnedAbout[warningKey]) {
continue;
}
warnedAbout[warningKey] = true;
error('%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey);
}
}
}
}
|
When mixing shorthand and longhand property names, we warn during updates if
we expect an incorrect result to occur. In particular, we warn for:
Updating a shorthand property (longhand gets overwritten):
{font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
becomes .style.font = 'baz'
Removing a shorthand property (longhand gets lost too):
{font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
becomes .style.font = ''
Removing a longhand property (should revert to shorthand; doesn't):
{font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
becomes .style.fontVariant = ''
|
validateShorthandPropertyCollisionInDev
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function assertValidProps(tag, props) {
if (!props) {
return;
} // Note the use of `==` which checks for null or undefined.
if (voidElementTags[tag]) {
if (props.children != null || props.dangerouslySetInnerHTML != null) {
throw new Error(tag + " is a void element tag and must neither have `children` nor " + 'use `dangerouslySetInnerHTML`.');
}
}
if (props.dangerouslySetInnerHTML != null) {
if (props.children != null) {
throw new Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.');
}
if (typeof props.dangerouslySetInnerHTML !== 'object' || !(HTML in props.dangerouslySetInnerHTML)) {
throw new Error('`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://reactjs.org/link/dangerously-set-inner-html ' + 'for more information.');
}
}
{
if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
error('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.');
}
}
if (props.style != null && typeof props.style !== 'object') {
throw new Error('The `style` prop expects a mapping from style properties to values, ' + "not a string. For example, style={{marginRight: spacing + 'em'}} when " + 'using JSX.');
}
}
|
When mixing shorthand and longhand property names, we warn during updates if
we expect an incorrect result to occur. In particular, we warn for:
Updating a shorthand property (longhand gets overwritten):
{font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
becomes .style.font = 'baz'
Removing a shorthand property (longhand gets lost too):
{font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
becomes .style.font = ''
Removing a longhand property (should revert to shorthand; doesn't):
{font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
becomes .style.fontVariant = ''
|
assertValidProps
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
function isCustomComponent(tagName, props) {
if (tagName.indexOf('-') === -1) {
return typeof props.is === 'string';
}
switch (tagName) {
// These are reserved SVG and MathML elements.
// We don't mind this list too much because we expect it to never grow.
// The alternative is to track the namespace in a few places which is convoluted.
// https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
case 'annotation-xml':
case 'color-profile':
case 'font-face':
case 'font-face-src':
case 'font-face-uri':
case 'font-face-format':
case 'font-face-name':
case 'missing-glyph':
return false;
default:
return true;
}
}
|
When mixing shorthand and longhand property names, we warn during updates if
we expect an incorrect result to occur. In particular, we warn for:
Updating a shorthand property (longhand gets overwritten):
{font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
becomes .style.font = 'baz'
Removing a shorthand property (longhand gets lost too):
{font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
becomes .style.font = ''
Removing a longhand property (should revert to shorthand; doesn't):
{font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
becomes .style.fontVariant = ''
|
isCustomComponent
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-dom-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-dom-v18.dev.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.