eleventy-plugin-react icon indicating copy to clipboard operation
eleventy-plugin-react copied to clipboard

Move away from JSDOM for comment transformation

Open kaicataldo opened this issue 3 years ago • 0 comments

The current marker generation logic takes multiple passes to generate the marker comments for the client-side hydration step.

  1. It renders a script tag with the necessary data serialized as data attributes.
  2. Post-rendering to string, the plugin manually replaces these script tags with HTML comments to avoid breaking any styles that might rely sibling selectors.

This second step currently uses JSDOM as a quick-and-dirty way to get it working, but this is probably overkill for what we're doing here, and a simpler string replacement would probably be more performant since we don't need access to all the DOM APIs to do this transformation.

kaicataldo avatar Jan 10 '22 00:01 kaicataldo