From 9e00e156588d45e4929d2500b8f4d525da1aa56f Mon Sep 17 00:00:00 2001 From: Jason Johnston Date: Wed, 12 Apr 2023 14:00:04 -0400 Subject: [PATCH] [RNMobile] Add viewport optional props (#49699) * Add viewport optional props * Handle unwanted commas * Clean up regex * Update packages/components/src/sandbox/index.native.js Co-authored-by: Carlos Garcia --------- Co-authored-by: jhnstn Co-authored-by: Carlos Garcia --- packages/components/src/sandbox/index.native.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/components/src/sandbox/index.native.js b/packages/components/src/sandbox/index.native.js index f374e07dec4e3..2cbfe9bf1a9ba 100644 --- a/packages/components/src/sandbox/index.native.js +++ b/packages/components/src/sandbox/index.native.js @@ -185,6 +185,7 @@ const Sandbox = forwardRef( function Sandbox( type, url, onWindowEvents = {}, + viewportProps = '', }, ref ) { @@ -213,13 +214,19 @@ const Sandbox = forwardRef( function Sandbox( // we can use this in the future to inject custom styles or scripts. // Scripts go into the body rather than the head, to support embedded content such as Instagram // that expect the scripts to be part of the body. + + // Avoid comma issues with props.viewportProps. + const addViewportProps = viewportProps + .trim() + .replace( /(^[^,])/, ', $1' ); + const htmlDoc = ( { title }