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

Text Content being duplicated #4

Open
barelyhuman opened this issue May 6, 2023 · 2 comments
Open

Text Content being duplicated #4

barelyhuman opened this issue May 6, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@barelyhuman
Copy link
Owner

Any island tree being constructed inside a textContent based DOM Node get's replicated.

Example:

const HelloIsland = ()=>{
 return <h1>Hello</h1>
}


export const get = (ctx)=>{
  return (
    <>
      <p>
        <HelloIsland />
      </p>
    </>
  );
}

Would end up creating multiple <h1> and p tags

@barelyhuman barelyhuman added the bug Something isn't working label May 6, 2023
@barelyhuman barelyhuman self-assigned this May 6, 2023
@barelyhuman
Copy link
Owner Author

This is only in cases where the island renders an invalid semantic child,

example:

<p>
 <h1>
  Hello World
 </h1>
</p>

This is to be caught at the AST level since preact will go ahead and render it as sibling when the component is rendered with an island.

The other option is to generate a text node tree like fresh does but that would make the rendering a little more complicated.

@barelyhuman
Copy link
Owner Author

The reason for this is as listed in this issue
preactjs/preact#4093

Possible solutions

  • Wait for preact/debug to handle this
  • Handle it on the AST level with a DOM/JSX Tree sanitizer
  • Handle it on the AST level with a warning for known cases from the spec instead of sanitizing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant