Skip to content

Commit 21158df

Browse files
committed
Fix remaining files after stricter check
1 parent e0051d8 commit 21158df

4 files changed

Lines changed: 46 additions & 36 deletions

File tree

packages/react-dom/src/shared/sanitizeURL.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ function sanitizeURL(url: string) {
3838
'React has blocked a javascript: URL as a security precaution.%s',
3939
__DEV__ ? ReactDebugCurrentFrame.getStackAddendum() : '',
4040
);
41-
} else if (__DEV__ && !didWarn && isJavaScriptProtocol.test(url)) {
42-
didWarn = true;
43-
warning(
44-
false,
45-
'A future version of React will block javascript: URLs as a security precaution. ' +
46-
'Use event handlers instead if you can. If you need to generate unsafe HTML try ' +
47-
'using dangerouslySetInnerHTML instead. React was passed %s.',
48-
JSON.stringify(url),
49-
);
41+
} else if (__DEV__) {
42+
if (!didWarn && isJavaScriptProtocol.test(url)) {
43+
didWarn = true;
44+
warning(
45+
false,
46+
'A future version of React will block javascript: URLs as a security precaution. ' +
47+
'Use event handlers instead if you can. If you need to generate unsafe HTML try ' +
48+
'using dangerouslySetInnerHTML instead. React was passed %s.',
49+
JSON.stringify(url),
50+
);
51+
}
5052
}
5153
}
5254

packages/react-reconciler/src/ReactFiberDevToolsHook.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,31 @@ export function injectInternals(internals: Object): boolean {
8989
hook.onCommitFiberRoot(rendererID, root, undefined, didError);
9090
}
9191
} catch (err) {
92-
if (__DEV__ && !hasLoggedError) {
93-
hasLoggedError = true;
94-
warningWithoutStack(
95-
false,
96-
'React instrumentation encountered an error: %s',
97-
err,
98-
);
92+
if (__DEV__) {
93+
if (!hasLoggedError) {
94+
hasLoggedError = true;
95+
warningWithoutStack(
96+
false,
97+
'React instrumentation encountered an error: %s',
98+
err,
99+
);
100+
}
99101
}
100102
}
101103
};
102104
onCommitFiberUnmount = fiber => {
103105
try {
104106
hook.onCommitFiberUnmount(rendererID, fiber);
105107
} catch (err) {
106-
if (__DEV__ && !hasLoggedError) {
107-
hasLoggedError = true;
108-
warningWithoutStack(
109-
false,
110-
'React instrumentation encountered an error: %s',
111-
err,
112-
);
108+
if (__DEV__) {
109+
if (!hasLoggedError) {
110+
hasLoggedError = true;
111+
warningWithoutStack(
112+
false,
113+
'React instrumentation encountered an error: %s',
114+
err,
115+
);
116+
}
113117
}
114118
}
115119
};

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,12 +1089,14 @@ export function flushDiscreteUpdates() {
10891089
(executionContext & (BatchedContext | RenderContext | CommitContext)) !==
10901090
NoContext
10911091
) {
1092-
if (__DEV__ && (executionContext & RenderContext) !== NoContext) {
1093-
warning(
1094-
false,
1095-
'unstable_flushDiscreteUpdates: Cannot flush updates when React is ' +
1096-
'already rendering.',
1097-
);
1092+
if (__DEV__) {
1093+
if ((executionContext & RenderContext) !== NoContext) {
1094+
warning(
1095+
false,
1096+
'unstable_flushDiscreteUpdates: Cannot flush updates when React is ' +
1097+
'already rendering.',
1098+
);
1099+
}
10981100
}
10991101
// We're already rendering, so we can't synchronously flush pending work.
11001102
// This is probably a nested event dispatch triggered by a lifecycle/effect,

packages/react-test-renderer/src/ReactTestHostConfig.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,15 @@ export function createTextInstance(
214214
hostContext: Object,
215215
internalInstanceHandle: Object,
216216
): TextInstance {
217-
if (__DEV__ && enableFlareAPI) {
218-
warning(
219-
hostContext !== EVENT_COMPONENT_CONTEXT,
220-
'validateDOMNesting: React event components cannot have text DOM nodes as children. ' +
221-
'Wrap the child text "%s" in an element.',
222-
text,
223-
);
217+
if (__DEV__) {
218+
if (enableFlareAPI) {
219+
warning(
220+
hostContext !== EVENT_COMPONENT_CONTEXT,
221+
'validateDOMNesting: React event components cannot have text DOM nodes as children. ' +
222+
'Wrap the child text "%s" in an element.',
223+
text,
224+
);
225+
}
224226
}
225227
return {
226228
text,

0 commit comments

Comments
 (0)