Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trusted types to react on server side #16555

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' of https://github.com/facebook/react into tt-re…
…act-server
  • Loading branch information
Emanuel Tesar committed Aug 23, 2019
commit df6577bb510cc041b110fc7c73203ab232e777fd
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,5 @@ module.exports = {
spyOnProd: true,
__PROFILE__: true,
__UMD__: true,
TrustedTypes: true,
},
};
6 changes: 3 additions & 3 deletions packages/react-dom/src/server/DOMMarkupOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @flow
*/
import type {TrustedTypes} from './trustedTypes';
import type {TrustedTypePolicyFactory} from './trustedTypes';

import {
ID_ATTRIBUTE_NAME,
Expand Down Expand Up @@ -45,14 +45,14 @@ export function createMarkupForRoot(): string {
* @param {string} name property name
* @param {*} value property value
* @param {string} tagLowercase lowercase tag name of the target element
* @param {TrustedTypes} trustedTypes Trusted Types implementation, which if provided enforces trusted types on server
* @param {TrustedTypePolicyFactory} trustedTypes Trusted Types implementation, which if provided enforces trusted types on server
* @return {?string} Markup string, or null if the property was invalid.
*/
export function createMarkupForProperty(
name: string,
value: mixed,
tagLowercase: string,
trustedTypes: ?TrustedTypes,
trustedTypes: ?TrustedTypePolicyFactory,
): string {
const propertyInfo = getPropertyInfo(name);
if (name !== 'style' && shouldIgnoreAttribute(name, propertyInfo, false)) {
Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {ThreadID} from './ReactThreadIDAllocator';
import type {ReactElement} from 'shared/ReactElementType';
import type {LazyComponent} from 'shared/ReactLazyComponent';
import type {ReactProvider, ReactContext} from 'shared/ReactTypes';
import type {TrustedTypes} from './trustedTypes';
import type {TrustedTypePolicyFactory} from './trustedTypes';

import React from 'react';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -368,7 +368,7 @@ function createOpenTagMarkup(
namespace: string,
makeStaticMarkup: boolean,
isRootElement: boolean,
trustedTypes: ?TrustedTypes,
trustedTypes: ?TrustedTypePolicyFactory,
): string {
let ret = '<' + tagVerbatim;

Expand Down Expand Up @@ -736,7 +736,7 @@ class ReactDOMServerRenderer {
currentSelectValue: any;
previousWasTextNode: boolean;
makeStaticMarkup: boolean;
trustedTypes: ?TrustedTypes;
trustedTypes: ?TrustedTypePolicyFactory;
suspenseDepth: number;

contextIndex: number;
Expand All @@ -747,7 +747,7 @@ class ReactDOMServerRenderer {
constructor(
children: mixed,
makeStaticMarkup: boolean,
trustedTypes?: TrustedTypes,
trustedTypes?: TrustedTypePolicyFactory,
) {
const flatChildren = flattenTopLevelChildren(children);

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/trustedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*/

// TODO: create a flow typed for trusted types
export type TrustedTypes = any;
export type TrustedTypePolicyFactory = any;
2 changes: 0 additions & 2 deletions scripts/rollup/validate/eslintrc.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ module.exports = {
process: true,
setImmediate: true,
Buffer: true,
// Trusted Types
TrustedTypes: true,
},
parserOptions: {
ecmaVersion: 5,
Expand Down
2 changes: 0 additions & 2 deletions scripts/rollup/validate/eslintrc.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ module.exports = {
// Node.js Server Rendering
setImmediate: true,
Buffer: true,
// Trusted Types
TrustedTypes: true,
},
parserOptions: {
ecmaVersion: 5,
Expand Down
2 changes: 0 additions & 2 deletions scripts/rollup/validate/eslintrc.rn.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ module.exports = {
// Fabric. See https://github.com/facebook/react/pull/15490
// for more information
nativeFabricUIManager: true,
// Trusted Types
TrustedTypes: true,
},
parserOptions: {
ecmaVersion: 5,
Expand Down
2 changes: 0 additions & 2 deletions scripts/rollup/validate/eslintrc.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ module.exports = {
define: true,
require: true,
global: true,
// Trusted Types
TrustedTypes: true,
},
parserOptions: {
ecmaVersion: 5,
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.