Giter Site home page Giter Site logo

Comments (8)

Wildhoney avatar Wildhoney commented on August 19, 2024 1

Absolutely – we could do that, although it's making an assumption about the type of node to create, rather than taking it directly from your first child. I suppose we could accept an additional prop, such as wrapperNode.

Thoughts?

from reactshadow.

Wildhoney avatar Wildhoney commented on August 19, 2024 1

I've taken a look at this again, and there are two issues, one of which we've spoken about:

  • For <child.type> we don't have access to the type when the props.children is another component, and so we have to traverse through the children to find the first concrete element.
  • With findDOMNode when the props.children is a concrete element it yields the node which we can attach a shadow boundary to. However when it's another component it yields null and thus we cannot attach a shadow boundary to that – we need a way to find the concrete node.

I can achieve the former, but the latter I'm not sure about at the moment.

Does anybody have any suggestions?

from reactshadow.

mhuggins avatar mhuggins commented on August 19, 2024

FWIW, I was able to resolve this by throwing a <div> between and`, but not completely sure why it's needed. Might be good to add clarity in the README! Feel free to close this though.

from reactshadow.

Wildhoney avatar Wildhoney commented on August 19, 2024

We have the check for passing a HTML node rather than a wrapped component, as ReactShadow needs to be able to determine the type of the node to append the shadow boundary to – otherwise it would have to recursively traverse the tree until it finds the first HTML node.

<div /> // this.props.children.type === 'div'
<WrappedComponent>
    <div /> // this.props.children.props.children.type === 'div'
</WrappedComponent>

We could do that, but it may have unforeseen consequences.

from reactshadow.

mhuggins avatar mhuggins commented on August 19, 2024

Is it because the shadow DOM function is called on the first HTML node it comes across? If so, how come the ShadowDOM component itself can't just create its own DOM element to us?

from reactshadow.

javadoug avatar javadoug commented on August 19, 2024

@Wildhoney regarding the finding the concrete child issue: First, I suggest making the error message clear to add an HTML DOM as first child of ShadowDOM so error gives fix, no need to search/waste time. Second, optionally add a shadowRoot prop that takes a String, or Node or whatever else you can accept as value.

from reactshadow.

nestarz avatar nestarz commented on August 19, 2024

How can I include css from my Component without being ignored ? Is it possible ?

from reactshadow.

Wildhoney avatar Wildhoney commented on August 19, 2024

Should work just fine with the updated version.

from reactshadow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.