From 7ea792d532e0aec488d7e84c99a416c9d651671f Mon Sep 17 00:00:00 2001 From: Josh Story Date: Thu, 2 Mar 2023 16:15:51 -0800 Subject: [PATCH] support spaces in style data-hrefs attribute by escaping them --- .../src/client/ReactDOMFloatClient.js | 46 ++++++++++++-- .../src/server/ReactDOMServerFormatConfig.js | 47 ++++++++++++-- .../src/__tests__/ReactDOMFloat-test.js | 61 +++++++++++++++++++ 3 files changed, 144 insertions(+), 10 deletions(-) diff --git a/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js b/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js index 89e7f6bc0ac29..7598f9b64225b 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js +++ b/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js @@ -661,21 +661,34 @@ function styleTagPropsFromRawProps( } function getStyleKey(href: string) { - const limitedEscapedHref = - escapeSelectorAttributeValueInsideDoubleQuotes(href); - return `href~="${limitedEscapedHref}"`; + return href; } function getStyleTagSelectorFromKey(key: string) { - return `style[data-${key}]`; + // Key is actually the href + // @TODO refactor. It was convient before when the key being the selector was sufficient + // but with the complexities introduced with + + + + + + + ); + } + await actIntoEmptyDocument(() => { + renderToPipeableStream().pipe(writable); + }); + expect(getMeaningfulChildren(document)).toEqual( + + + + + + , + ); + + // If the hydration selector failed to match on quote + ReactDOMClient.hydrateRoot(document, ); + expect(Scheduler).toFlushWithoutYielding(); + expect(getMeaningfulChildren(document)).toEqual( + + + + + + , + ); + }); }); describe('Script Resources', () => {