mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
DevTools: Replaced unsafe hasOwnProperty() calls (#17768)
DevTools previously called in several places with user-defined values. This could lead to runtime errors if those values had an overriden attribute. This commit replaces those callse with instead. New test cases have been added.
This commit is contained in:
@@ -78,7 +78,7 @@ export default function KeyValue({
|
||||
type:
|
||||
value !== null &&
|
||||
typeof value === 'object' &&
|
||||
value.hasOwnProperty(meta.type)
|
||||
hasOwnProperty.call(value, meta.type)
|
||||
? value[meta.type]
|
||||
: typeof value,
|
||||
},
|
||||
@@ -136,8 +136,8 @@ export default function KeyValue({
|
||||
</div>
|
||||
);
|
||||
} else if (
|
||||
value.hasOwnProperty(meta.type) &&
|
||||
!value.hasOwnProperty(meta.unserializable)
|
||||
hasOwnProperty.call(value, meta.type) &&
|
||||
!hasOwnProperty.call(value, meta.unserializable)
|
||||
) {
|
||||
children = (
|
||||
<div
|
||||
|
||||
@@ -93,7 +93,7 @@ export function createRegExp(string: string): RegExp {
|
||||
}
|
||||
|
||||
export function getMetaValueLabel(data: Object): string | null {
|
||||
if (data.hasOwnProperty(meta.preview_long)) {
|
||||
if (hasOwnProperty.call(data, meta.preview_long)) {
|
||||
return data[meta.preview_long];
|
||||
} else {
|
||||
return formatDataForPreview(data, true);
|
||||
|
||||
Reference in New Issue
Block a user