Clarifications

Co-authored-by: shengxinjing <316783812@qq.com>
This commit is contained in:
Rick Hanlon 2020-06-12 21:02:51 -04:00
parent 103ed08c46
commit 655affa302
15 changed files with 43 additions and 43 deletions

View File

@ -782,7 +782,7 @@ Starting with 16.1.0, we will no longer be publishing new releases on Bower. You
* Fix bug in QtWebKit when wrapping synthetic events in proxies. ([@walrusfruitcake](https://github.com/walrusfruitcake) in [#10115](https://github.com/facebook/react/pull/10011))
* Prevent event handlers from receiving extra argument in development. ([@aweary](https://github.com/aweary) in [#10115](https://github.com/facebook/react/pull/8363))
* Fix cases where `onChange` would not fire with `defaultChecked` on radio inputs. ([@jquense](https://github.com/jquense) in [#10156](https://github.com/facebook/react/pull/10156))
* Add support for `controlList` attribute to DOM property whitelist ([@nhunzaker](https://github.com/nhunzaker) in [#9940](https://github.com/facebook/react/pull/9940))
* Add support for `controlList` attribute to allowed DOM properties ([@nhunzaker](https://github.com/nhunzaker) in [#9940](https://github.com/facebook/react/pull/9940))
* Fix a bug where creating an element with a ref in a constructor did not throw an error in development. ([@iansu](https://github.com/iansu) in [#10025](https://github.com/facebook/react/pull/10025))
## 15.6.1 (June 14, 2017)

View File

@ -85,7 +85,7 @@ const consoleSettingsRef = {
breakOnConsoleErrors: false,
};
// Patches whitelisted console methods to append component stack for the current fiber.
// Patches console methods to append component stack for the current fiber.
// Call unpatch() to remove the injected behavior.
export function patch({
appendComponentStack,
@ -184,7 +184,7 @@ export function patch({
});
}
// Removed component stack patch from whitelisted console methods.
// Removed component stack patch from console methods.
export function unpatch(): void {
if (unpatchFn !== null) {
unpatchFn();

View File

@ -586,10 +586,10 @@ export function attach(
});
}
function createIsPathWhitelisted(key: string) {
function createisPathAllowed(key: string) {
// This function helps prevent previously-inspected paths from being dehydrated in updates.
// This is important to avoid a bad user experience where expanded toggles collapse on update.
return function isPathWhitelisted(path: Array<string | number>): boolean {
return function isPathAllowed(path: Array<string | number>): boolean {
let current = currentlyInspectedPaths[key];
if (!current) {
return false;
@ -706,15 +706,15 @@ export function attach(
inspectedElement.context = cleanForBridge(
inspectedElement.context,
createIsPathWhitelisted('context'),
createisPathAllowed('context'),
);
inspectedElement.props = cleanForBridge(
inspectedElement.props,
createIsPathWhitelisted('props'),
createisPathAllowed('props'),
);
inspectedElement.state = cleanForBridge(
inspectedElement.state,
createIsPathWhitelisted('state'),
createisPathAllowed('state'),
);
return {

View File

@ -2380,13 +2380,13 @@ export function attach(
});
}
function createIsPathWhitelisted(
function createisPathAllowed(
key: string | null,
secondaryCategory: 'hooks' | null,
) {
// This function helps prevent previously-inspected paths from being dehydrated in updates.
// This is important to avoid a bad user experience where expanded toggles collapse on update.
return function isPathWhitelisted(path: Array<string | number>): boolean {
return function isPathAllowed(path: Array<string | number>): boolean {
switch (secondaryCategory) {
case 'hooks':
if (path.length === 1) {
@ -2528,7 +2528,7 @@ export function attach(
((mostRecentlyInspectedElement: any): InspectedElement),
path,
),
createIsPathWhitelisted(null, secondaryCategory),
createisPathAllowed(null, secondaryCategory),
path,
),
};
@ -2573,19 +2573,19 @@ export function attach(
const cleanedInspectedElement = {...mostRecentlyInspectedElement};
cleanedInspectedElement.context = cleanForBridge(
cleanedInspectedElement.context,
createIsPathWhitelisted('context', null),
createisPathAllowed('context', null),
);
cleanedInspectedElement.hooks = cleanForBridge(
cleanedInspectedElement.hooks,
createIsPathWhitelisted('hooks', 'hooks'),
createisPathAllowed('hooks', 'hooks'),
);
cleanedInspectedElement.props = cleanForBridge(
cleanedInspectedElement.props,
createIsPathWhitelisted('props', null),
createisPathAllowed('props', null),
);
cleanedInspectedElement.state = cleanForBridge(
cleanedInspectedElement.state,
createIsPathWhitelisted('state', null),
createisPathAllowed('state', null),
);
return {

View File

@ -14,7 +14,7 @@ import type {DehydratedData} from 'react-devtools-shared/src/devtools/views/Comp
export function cleanForBridge(
data: Object | null,
isPathWhitelisted: (path: Array<string | number>) => boolean,
isPathAllowed: (path: Array<string | number>) => boolean,
path?: Array<string | number> = [],
): DehydratedData | null {
if (data !== null) {
@ -25,7 +25,7 @@ export function cleanForBridge(
cleanedPaths,
unserializablePaths,
path,
isPathWhitelisted,
isPathAllowed,
);
return {

View File

@ -164,7 +164,7 @@ function Row({
// The list of valid attributes would need to be injected by RN backend,
// which would need to require them from ReactNativeViewViewConfig "validAttributes.style" keys.
// This would need to degrade gracefully for react-native-web,
// althoguh we could let it also inject a custom set of whitelisted attributes.
// although we could let it also inject a custom set of allowed attributes.
const [localAttribute, setLocalAttribute] = useState(attribute);
const [localValue, setLocalValue] = useState(JSON.stringify(value));

View File

@ -121,7 +121,7 @@ export function dehydrate(
cleaned: Array<Array<string | number>>,
unserializable: Array<Array<string | number>>,
path: Array<string | number>,
isPathWhitelisted: (path: Array<string | number>) => boolean,
isPathAllowed: (path: Array<string | number>) => boolean,
level?: number = 0,
):
| string
@ -132,7 +132,7 @@ export function dehydrate(
| {[key: string]: string | Dehydrated | Unserializable, ...} {
const type = getDataType(data);
let isPathWhitelistedCheck;
let isPathAllowedCheck;
switch (type) {
case 'html_element':
@ -204,8 +204,8 @@ export function dehydrate(
};
case 'array':
isPathWhitelistedCheck = isPathWhitelisted(path);
if (level >= LEVEL_THRESHOLD && !isPathWhitelistedCheck) {
isPathAllowedCheck = isPathAllowed(path);
if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
return createDehydrated(type, true, data, cleaned, path);
}
return data.map((item, i) =>
@ -214,15 +214,15 @@ export function dehydrate(
cleaned,
unserializable,
path.concat([i]),
isPathWhitelisted,
isPathWhitelistedCheck ? 1 : level + 1,
isPathAllowed,
isPathAllowedCheck ? 1 : level + 1,
),
);
case 'typed_array':
case 'iterator':
isPathWhitelistedCheck = isPathWhitelisted(path);
if (level >= LEVEL_THRESHOLD && !isPathWhitelistedCheck) {
isPathAllowedCheck = isPathAllowed(path);
if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
return createDehydrated(type, true, data, cleaned, path);
} else {
const unserializableValue: Unserializable = {
@ -250,8 +250,8 @@ export function dehydrate(
cleaned,
unserializable,
path.concat([i]),
isPathWhitelisted,
isPathWhitelistedCheck ? 1 : level + 1,
isPathAllowed,
isPathAllowedCheck ? 1 : level + 1,
)),
);
}
@ -282,8 +282,8 @@ export function dehydrate(
};
case 'object':
isPathWhitelistedCheck = isPathWhitelisted(path);
if (level >= LEVEL_THRESHOLD && !isPathWhitelistedCheck) {
isPathAllowedCheck = isPathAllowed(path);
if (level >= LEVEL_THRESHOLD && !isPathAllowedCheck) {
return createDehydrated(type, true, data, cleaned, path);
} else {
const object = {};
@ -293,8 +293,8 @@ export function dehydrate(
cleaned,
unserializable,
path.concat([name]),
isPathWhitelisted,
isPathWhitelistedCheck ? 1 : level + 1,
isPathAllowed,
isPathAllowedCheck ? 1 : level + 1,
);
}
return object;

View File

@ -1058,7 +1058,7 @@ describe('ReactDOMComponent', () => {
expect(nodeValueSetter).toHaveBeenCalledTimes(3);
});
it('should ignore attribute whitelist for elements with the "is" attribute', () => {
it('should ignore attribute list for elements with the "is" attribute', () => {
const container = document.createElement('div');
ReactDOM.render(<button is="test" cowabunga="chevynova" />, container);
expect(container.firstChild.hasAttribute('cowabunga')).toBe(true);

View File

@ -755,7 +755,7 @@ export function diffProperties(
}
} else {
// For all other deleted properties we add it to the queue. We use
// the whitelist in the commit phase instead.
// the allowed property list in the commit phase instead.
(updatePayload = updatePayload || []).push(propKey, null);
}
}
@ -858,7 +858,7 @@ export function diffProperties(
nextProp.toString();
} else {
// For any other property we always add it to the queue and then we
// filter it out using the whitelist during the commit.
// filter it out using the allowed property list during the commit.
(updatePayload = updatePayload || []).push(propKey, nextProp);
}
}
@ -1029,7 +1029,7 @@ export function diffHydratedProperties(
for (let i = 0; i < attributes.length; i++) {
const name = attributes[i].name.toLowerCase();
switch (name) {
// Built-in SSR attribute is whitelisted
// Built-in SSR attribute is allowed
case 'data-reactroot':
break;
// Controlled attributes are not validated

View File

@ -154,7 +154,7 @@ export const TOP_BEFORE_BLUR = unsafeCastStringToDOMTopLevelType('beforeblur');
// List of events that need to be individually attached to media elements.
// Note that events in this list will *not* be listened to at the top level
// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
// unless they're explicitly listed in `ReactBrowserEventEmitter.listenTo`.
export const mediaEventTypes = [
TOP_ABORT,
TOP_CAN_PLAY,

View File

@ -19,7 +19,7 @@ type PropertyType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
export const RESERVED = 0;
// A simple string attribute.
// Attributes that aren't in the whitelist are presumed to have this type.
// Attributes that aren't in the filter are presumed to have this type.
export const STRING = 1;
// A string attribute that accepts booleans in React. In HTML, these are called
@ -449,7 +449,7 @@ const capitalize = token => token[1].toUpperCase();
// This is a list of all SVG attributes that need special casing, namespacing,
// or boolean value assignment. Regular attributes that just accept strings
// and have the same names are omitted, just like in the HTML whitelist.
// and have the same names are omitted, just like in the HTML attribute filter.
// Some of these attributes can be hard to find. This list was created by
// scraping the MDN documentation.
[

View File

@ -13,7 +13,7 @@ function isCustomComponent(tagName: string, props: Object) {
}
switch (tagName) {
// These are reserved SVG and MathML elements.
// We don't mind this whitelist too much because we expect it to never grow.
// 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':

View File

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
// For HTML, certain tags should omit their close tag. We keep a whitelist for
// For HTML, certain tags should omit their close tag. We keep a list for
// those special-case tags.
const omittedCloseTags = {

View File

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
// When adding attributes to the HTML or SVG whitelist, be sure to
// When adding attributes to the HTML or SVG allowed attribute list, be sure to
// also add them to this module to ensure casing and incorrect name
// warnings.
const possibleStandardNames = {

View File

@ -24,7 +24,7 @@ describe('Scheduling UMD bundle', () => {
});
function filterPrivateKeys(name) {
// Be very careful adding things to this whitelist!
// Be very careful adding things to this filter!
// It's easy to introduce bugs by doing it:
// https://github.com/facebook/react/issues/14904
switch (name) {